You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stack deploy fails if "target" or "published" port is a string #1073
The long form --publish published=<port>,target=<port> syntax currently does not support port-ranges (see #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.
@doxxxversion: "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)
Reacted by John HU, LK, tvkit, Alexander Teslowski, Marius Rugan, Zack, farrukhijaz, DevinDon, Bas van den Wollenberg, Igor Ohrimenko and 6 more
Reacted by Gordon Tyler, Maurizio Bussi, Louis Manabat, Jack Burch and Nicolas Graf
When attempting to deploy to Swarm, two errors will show:
services.syncthing.ports.0.published must be a integer
(root) Additional property name is not allowed
Why is the compose file that is generated using the Docker compose plugin not compatible with Docker stack deploy out of the box?
Edit: For whoever that stumbles upon this issue again, my current workaround is to pin the version of Docker I am using to deploy to a version < 20.10.15.
Seems like compose was integrated into Docker Engine version 20.10.15 and onward. I suspect something has changed in the way docker stack deploy reads the config file to deploy to Swarm, but I have yet to look into it myself, to be frank.
Reacted by Marco Ost, Vitalii Rybalko, nelsonpoon, Lluc Martorell, ruben-sdc, Sebastian Fischer, Ziemowit, L. D. Nicolas May, kodyrecords, MUsoftware and 5 more
When attempting to deploy to Swarm, two errors will show:
services.syncthing.ports.0.published must be a integer
(root) Additional property name is not allowed
Why is the compose file that is generated using the Docker compose plugin not compatible with Docker stack deploy out of the box?
Edit: For whoever that stumbles upon this issue again, my current workaround is to pin the version of Docker I am using to deploy to a version < 20.10.15.
Seems like compose was integrated into Docker Engine version 20.10.15 and onward. I suspect something has changed in the way docker stack deploy reads the config file to deploy to Swarm, but I have yet to look into it myself, to be frank.
I have same problem,
Verison : Docker version 20.10.17, build 100c701
Error : services.[ProjectName].ports.0 must be a string or number
I'm using docker compose to interpolate env vars in a swarm stack file, unfortunately that insert port numbers with quotes. I'm using this yq expression to correct this in the long form:
Using docker compose -f "$COMPOSE_FILE" config | grep -v '^name:' | docker stack deploy -c - STACKNAME works fine if the compose file does not have published port etc., but requires sed manipulation.
Using docker stack config would be great, but i'm only getting:
"Configuration contains forbidden properties", without any helpful output.
I guess that docker stack config seems to support only a partial set of the compose features, but i feel it would be great to use them ;).
Activity
thaJeztah commentedon May 22, 2018
Discussing with @vdemeester; this also relates to #839
The long form
--publish published=<port>,target=<port>syntax currently does not support port-ranges (see #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.
doxxx commentedon Jun 7, 2018
EDIT: Changing the version to "3.5" made it work.
Changing both to an integer did not work for me.
Docker version 18.05.0-ce, build f150324
Windows 10
vdemeester commentedon Jun 7, 2018
@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)gordonpn commentedon Jun 29, 2022
This is happening with
Docker version 20.10.17, build 100c701.Fully defined Compose yaml config generated using
docker compose convertwould give something like:(
version: "3.9"is added manually)When attempting to deploy to Swarm, two errors will show:
services.syncthing.ports.0.published must be a integer(root) Additional property name is not allowedWhy is the compose file that is generated using the Docker compose plugin not compatible with
Docker stack deployout of the box?Edit: For whoever that stumbles upon this issue again, my current workaround is to pin the version of Docker I am using to deploy to a version
< 20.10.15.Seems like
composewas integrated into Docker Engine version20.10.15and onward. I suspect something has changed in the waydocker stack deployreads the config file to deploy to Swarm, but I have yet to look into it myself, to be frank.nelsonpoon commentedon Aug 11, 2022
I have same problem,
Verison : Docker version 20.10.17, build 100c701
Error : services.[ProjectName].ports.0 must be a string or number
Change on yml
to
Update:
I have fix the problem, by change the version to 3.4
from
to
diegobill commentedon Feb 10, 2023
workaround using sed:
build(deploy): parse compose config with sed before pipe to stack deploy
build(deploy): parse compose config with sed before pipe to stack deploy
build(deploy): parse compose config with sed before pipe to stack deploy
pschichtel commentedon Mar 25, 2025
I'm using docker compose to interpolate env vars in a swarm stack file, unfortunately that insert port numbers with quotes. I'm using this yq expression to correct this in the long form:
flanciskinho commentedon Apr 16, 2025
There is a
docker stack configto use on swarm.This option prevents you from converting invalid values generated by
docker compose config. Examples of invaliddocker compose configvalues:phroggar commentedon Jun 10, 2025
I'm using include and extends from docker compose to organize my swarm setup, example:
Using
docker compose -f "$COMPOSE_FILE" config | grep -v '^name:' | docker stack deploy -c - STACKNAMEworks fine if the compose file does not have published port etc., but requires sed manipulation.Using docker stack config would be great, but i'm only getting:
"Configuration contains forbidden properties", without any helpful output.
I guess that docker stack config seems to support only a partial set of the compose features, but i feel it would be great to use them ;).
cli/compose: accept numeric strings for long-form ports
refactor(gate,ansible,certbot): /simplify pass — dedupe, pin, doc pla…
refactor(gate,ansible,certbot): /simplify pass — dedupe, pin, doc pla…