As reported by @ushuz https://github.com/docker/cli/issues/229#issuecomment-381066533
version: '3.4'
services:
web:
image: nginx:alpine
ports:
- published: '8080'
target: 80
Deploying the above produces:
$ docker stack deploy -c docker-compose.yml hello
services.web.ports.0.published must be a integer
The same issue is present for target:
version: '3.4'
services:
web:
image: nginx:alpine
ports:
- published: 8080
target: '80'
$ docker stack deploy -c docker-compose.yml hello
services.web.ports.0.target must be a integer
Changing both to an integer makes this work:
version: '3.4'
services:
web:
image: nginx:alpine
ports:
- published: 8080
target: 80
$ docker stack deploy -c docker-compose.yml hello
Creating network hello_default
Creating service hello_web
Reproduced on:
Client:
Version: 18.05.0-ce
API version: 1.37
Go version: go1.9.5
Git commit: f150324
Built: Wed May 9 22:12:05 2018
OS/Arch: darwin/amd64
Experimental: true
Orchestrator: swarm
Server:
Engine:
Version: 18.05.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.10.1
Git commit: f150324
Built: Wed May 9 22:20:16 2018
OS/Arch: linux/amd64
Experimental: true
Discussing with @vdemeester; this also relates to https://github.com/docker/cli/issues/839
The long form --publish published=<port>,target=<port> syntax currently does not support port-ranges (see https://github.com/docker/cli/issues/839), and expects a single port to be passed (as integer)
While it's generally good to be _strict_ (we expect a number, so error if it's not a number), from a UX-perspective, I think (my 0.02c) it's ok to accept the port to be passed either as an integer, or as a string containing just a number.
EDIT: Changing the version to "3.5" made it work.
Changing both to an integer did _not_ work for me.
version: "3"
services:
db:
image: couchdb
ports:
- published: 5984
target: 5984
deploy:
restart_policy:
condition: on-failure
fs:
image: minio/minio
command: server /data
ports:
- published: 9001
target: 9000
deploy:
restart_policy:
condition: on-failure
PS> docker stack deploy --compose-file .\docker-compose.yml algdata
services.db.ports.0 must be a string or number
Docker version 18.05.0-ce, build f150324
Windows 10
@doxxx version: "3"聽means 3.0. The extend form of ports has been introduced in version 3.2, that's why you're getting this error. In version 3.0, ports only support a list of integer (or string)
Most helpful comment
@doxxx
version: "3"聽means3.0. The extend form ofportshas been introduced in version3.2, that's why you're getting this error. In version3.0,portsonly support a list of integer (or string)