Skip to content

v2.3.x config yaml output contains ports as strings #9306

@jsoriano

Description

@jsoriano

Description

docker-compose config formats the published port as a string, this can be a problem when parsing this output.

This starts to happen in 2.3.0.

In documentation ports appear as numbers.

Steps to reproduce the issue:

  1. Define a project with exposed ports.
  2. Run docker-compose config.
  3. published port is a string, while target port is a number.

Can be reproduced for example with this minimal docker-compose.yml:

version: "2.3"
services:
  web:
    image: "nginx"
    ports:
      - "8080:8080"

Describe the results you received:

$ docker-compose config
name: foo
services:
  web:
    image: nginx
    networks:
      default: null
    ports:
    - mode: ingress
      target: 8080
      published: "8080"
      protocol: tcp
networks:
  default:
    name: foo_default

Describe the results you expected:

$ docker-compose config
name: foo
services:
  web:
    image: nginx
    networks:
      default: null
    ports:
    - mode: ingress
      target: 8080
      published: 8080
      protocol: tcp
networks:
  default:
    name: foo_default

Additional information you deem important (e.g. issue happens only occasionally):

It seems to happen since 2.3.0, in 2.2.3 the result is the expected one.

Output of docker compose version:

Docker Compose version v2.3.3

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 327
 Server Version: 20.10.7
 Storage Driver: btrfs
  Build Version: Btrfs v4.4
  Library Version: 101
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.15.0-171-generic
 Operating System: Ubuntu 18.04.6 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.44GiB
 Name: voyager
 ID: R7WQ:DRKJ:F2ZK:EC7J:V3RF:4GRC:GPI6:AEDN:6GL4:VU3V:LU2U:4YE5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions