Docker Community Forums

Share and learn in the Docker community.

Update a published port of a service


(Robyf) #1

Is it possible with docker engine in swarm mode to update the published port of a service? The docker service update command help says:
–publish-add value Add or update a published port (default [])

But when I try it it doesn’t update the published port, it adds a new one as in this example:

$ docker service create --name=web --publish 7070:80 nginx
2pohfxke9k2a801a3i5pcbu0o

$ docker service inspect web
"Ports": [
{
“Protocol”: “tcp”,
“TargetPort”: 80,
“PublishedPort”: 7070
}
],

$ docker service update --publish-add 7080:80 web
web

$ docker service inspect web
"Ports": [
{
“Protocol”: “tcp”,
“TargetPort”: 80,
“PublishedPort”: 7070
},
{
“Protocol”: “tcp”,
“TargetPort”: 80,
“PublishedPort”: 7080
}
],

And the service is reachable at both 7070 and 7080 ports, while I was expecting the published port 7070 to be removed and 7080 to be added.

I tested this with docker 1.12.3 on debian jessie.