I use the Play-with-Docker platform to create a Swarm cluster with 3 Docker instances: 1 manager and 2 workers; then I create a service from the image nginx:alpine
:
docker service create -p 8080:80 --name nginx-app nginx:alpine
Things worked fine.
Then I update
the service to change the published port: instead of 8080
, now I want the published port to be 8081
. I ran this:
docker service update --publish-rm 8080 --publish-add 8081 nginx-app
But it did not remove the published port 8080
; instead it created another published port 30002
, this port 30002
mapped to 8081
What did I do wrong here? How can I change the published port?
question from:
https://stackoverflow.com/questions/65929883/docker-swarm-how-to-update-published-post 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…