skip to Main Content

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

enter image description here

What did I do wrong here? How can I change the published port?

2

Answers


  1. Remove those services and start it like this instead:

    docker service create -p 8081:80 --name nginx-app nginx:alpine

    Login or Signup to reply.
  2. The --publish-rm option takes the target port, not the published port:

    docker service update --publish-rm 80 --publish-add 8081:80 nginx-app
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search