Ports: Short syntax no longer works?

Has anyone else noticed/had a problem with short syntax no longer exposing ports properly?

i.e. this used to work for me:

ports:
   - 9017:80

but now it doesn’t, and I’m forced to do:

ports:
  - published: 9017
    target: 80
    protocol: 'tcp'
    mode: 'host'

I’ve looked but can’t really find any docs on this, or why it’s this way now?

Why do you think / how do you see that the short syntax doesn’t work?

Short syntax: ports don’t get exposed.
Long syntax: ports get exposed.

How do you know the ports are not exposed? What OS and Docker version are you running?

I should be slightly more concise; it’s been awhile since messing with this again, and just re-checked everything, and refreshed my memory.

Using the short syntax as shown above, used to expose both IP6 and IP4 ports, but now it only exposes IP6 ports.

For example, I just fired up a test container using this for the ports:

ports:
  - '9999:9999'

and then to check it, use:

netstat -lnt | awk '{print $4}'

It shows this (note no IP4 port 9999, but there is an IP6 9999):

Also, looking in Portainer, only shows this (no port 9999 shown at all, either 4 or 6):

image

Now, when I use long syntax:

  - published: 9999
    target: 9999
    protocol: 'tcp'
    mode: 'host'

image

System:

Client: Docker Engine - Community
Version: 24.0.7
API version: 1.43
Go version: go1.20.10
Git commit: afdd53b
Built: Thu Oct 26 09:08:01 2023
OS/Arch: linux/amd64
Context: default

Server: Docker Engine - Community
Engine:
Version: 24.0.7
API version: 1.43 (minimum version 1.12)
Go version: go1.20.10
Git commit: 311b9ff
Built: Thu Oct 26 09:08:01 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.26
GitCommit: 3dd1e886e55dd695541fdcd67420c2888645a495
runc:
Version: 1.1.10
GitCommit: v1.1.10-0-g18a0cb0
docker-init:
Version: 0.19.0
GitCommit: de40ad0

In WSL/Ubuntu/Windows 10

Addition:

I thought maybe something changed with Docker and now you must specify for example /tcp to the short syntax:

ports:
  - '9999:9999/tcp'

But after testing, it made no difference.

That’s an interesting finding, similar issues have been discussed here before. If you are sure it’s a bug, the best place for it is Github (link).

Well, let’s see if anyone even notices