Repository navigation
Open
Description
Description
docker cli does not support a method to publish a range of ports using the long form syntax.
Steps to reproduce the issue:
- When Deploying a container:
docker run -p mode=host,target=9900-9999,published=9900-9999,protocol=tcp -d hello-world - When Deploying a service:
See related issue: Long format for publish using port ranges returns an error moby/moby#32551 - When Deploying a container using docker-compose:
See related issue: Docker Compose does not support defining port ranges in long form. compose#5613
Describe the results you received:
PS D:\issue> docker run -p mode=host,target=9900-9999,published=9900-9999,protocol=tcp -d hello-world
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Invalid containerPort: mode=host,target=9900-9999,published=9900-9999,protocol=tcp.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
Describe the results you expected:
PS D:\issue> docker run -p mode=host,target=9900-9999,published=9900-9999,protocol=tcp -d hello-world
<ContainerId>
Impacts:
- Customers with needs to define a large range of port bindings must declare each port individually if they need to use the long form syntax. This is burdensome and I would prefer to see parity between the long and short form syntax.
Output of docker version:
PS D:\issue> docker version
Client:
Version: 17.12.0-ce
API version: 1.35
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:05:22 2017
OS/Arch: windows/amd64
Server:
Engine:
Version: 17.12.0-ce
API version: 1.35 (minimum version 1.24)
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:15:52 2017
OS/Arch: windows/amd64
Experimental: true
Output of docker info:
D:\issue> docker info
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 148
Server Version: 17.12.0-ce
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 15063 (15063.0.amd64fre.rs2_release.170317-1834)
Operating System: Windows 10 Pro
OSType: windows
Architecture: x86_64
CPUs: 24
Total Memory: 31.95GiB
Name: PMMP7-562
ID: 3NOE:IXLT:UD6I:BJXF:U3IE:UJIX:YUAO:HJZH:TLI2:ABHW:VB4K:BKB4
Docker Root Dir: D:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: -1
Goroutines: 25
System Time: 2018-01-26T12:02:47.4595705-06:00
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Related Issues:
- Long format for publish using port ranges returns an error moby/moby#32551
- Docker Compose does not support defining port ranges in long form. compose#5613
- Stack deploy fails if "target" or "published" port is a string #1073
- Validation for mapping a range of host-ports to a single container-port fails #1074
Reacted by faircopy, Serj Mes, Jesper Ek, cguentherTUChemnitz, Bret Fisher, Jesse, Vasilevsky Alexander, Yogesh Prasad, Brian Charbonneau, Ben Jackson and 1 more
Activity
thaJeztah commentedon May 22, 2018
Also related; #1074
thaJeztah commentedon May 22, 2018
I agree that this should be supported; If we want to accept port-ranges to be passed as well in the long form, we could either go for a "strict" approach;
Or use the existing "range" notation:
I think the first option is too verbose, and will be cumbersome to use. While I think we should should generally avoid using "microformats" in options (as they can be ambiguous; causing more issues than they resolve), in this case, I think the "range" notation is well-defined, and ok to use.
publish=8080-8090,8095,8097, because commas are already used as separator between values, and using them as part of a value will be hard to read, and can easily lead to confusion.-p 8080-8081:80-81) notation, this should be a client-side change; the given port-ranges are parsed in the CLI, and sent as individual ports through the API; so from an API perspective,-p 8080-8081:80-81is the exact equivalent of-p 8080:80 -p 8081:81estenrye commentedon May 23, 2018
@thaJeztah I think I like the shorter more terse syntax of the existing range notation.
I agree that you probably shouldn't support disjointed ranges
publish=8080-8090,8095,8097for the reasons you have already stated and the fact that a user could implement a disjointed range by using multiple--publisharguments like so:hogmoru commentedon Jun 8, 2019
Hmm, this works for me on Linux with 18.09.5, and 19.09.0-dev (built from current sources). It fails with 18.03-0-ce.
Ran a few tests with various versions, looks like this is fixed since #1102 was merged... Or have I missed something?
jerradpatch commentedon Jun 12, 2020
If it is fixed it could use some updates in the docs. I wanted this option and landed here while searching for it.
0x0elliot commentedon Nov 22, 2022
this works as far as i know. shouldn't this be closed now?