Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid type of Published attribute in ServicePortConfig #312

Closed
AhmedGrati opened this issue Oct 16, 2022 · 4 comments
Closed

Invalid type of Published attribute in ServicePortConfig #312

AhmedGrati opened this issue Oct 16, 2022 · 4 comments

Comments

@AhmedGrati
Copy link

Description

In the ServicePortConfig struct, the Published attribute is of type string. However, such implementation led to some problems when in docker-compose. In fact, considering this docker-compose YAML file:

version: "3.9"
services:
  nginx:
    image: nginx
    ports:
      - "80:80"

The output of the command docker compose convert is the following

name: compose
services:
  nginx:
    image: nginx
    networks:
      default: null
    ports:
    - mode: ingress
      target: 80
      published: "80"
      protocol: tcp
networks:
  default:
    name: compose_default

As you can see, the published attribute is of string type, which lead to this error while executing docker stack deploy:

services.nginx.ports.0.published must be a integer

This issue is mainly related to an issue raised in docker compose repository.

@AhmedGrati
Copy link
Author

If this issue is valid I would love to work on it 🙏.

@glours
Copy link
Collaborator

glours commented Oct 17, 2022

@AhmedGrati you can work on custom marshaller/unmarshaller but you need to keep in mind that Compose Specification allow usage of ports range declaration such as "8000-9000:80"

@AhmedGrati
Copy link
Author

@glours Since the Published attribute is of String type, even after implementing a custom marshaller/unmarshaller, the output would remain in String type, isn't it? Please correct me if I'm missing something. 🙏

@ndeloof
Copy link
Collaborator

ndeloof commented Mar 27, 2023

Published is indeed a string as a it can be used to declare a range, not just a fixed port. This is the expected behavior.
docker stack not following the compose specification is tracked on docker/cli#2527

@ndeloof ndeloof closed this as completed Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants