Skip to content

Renaming service doesn't rename service tasks / containers #25483

@thaJeztah

Description

@thaJeztah

Renaming a service doesn't rename/update the services's containers/tasks:

$ docker service create --name web nginx:alpine
9qmzbansw53tteaocl2uhgf3v

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                  PORTS               NAMES
e4e8461a30d2        nginx:alpine        "nginx -g 'daemon off"   1 seconds ago       Up Less than a second   80/tcp, 443/tcp     web.1.2onlllux6w6haprqyjpzyx2fz

$ docker service update --name frontend web
web

$ docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
e4e8461a30d2        nginx:alpine        "nginx -g 'daemon off"   2 minutes ago       Up 2 minutes        80/tcp, 443/tcp     web.1.2onlllux6w6haprqyjpzyx2fz

New containers/tasks are named after the new service name:

$ docker service update --replicas=2 frontend
frontend

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
dd3d2f10b9ec        nginx:alpine        "nginx -g 'daemon off"   11 seconds ago      Up 10 seconds       80/tcp, 443/tcp     frontend.2.38oyjutl1ljis0a3n2psimmfd
e4e8461a30d2        nginx:alpine        "nginx -g 'daemon off"   3 minutes ago       Up 3 minutes        80/tcp, 443/tcp     web.1.2onlllux6w6haprqyjpzyx2fz

It becomes more confusing if you inspect the containers;


$ docker inspect frontend.2.38oyjutl1ljis0a3n2psimmfd

"Labels": {
      "com.docker.swarm.node.id": "f0k5s1khmlk9d0fnnbt3fmchx",
      "com.docker.swarm.service.id": "9qmzbansw53tteaocl2uhgf3v",
      "com.docker.swarm.service.name": "frontend",
      "com.docker.swarm.task": "",
      "com.docker.swarm.task.id": "38oyjutl1ljis0a3n2psimmfd",
      "com.docker.swarm.task.name": "frontend.2"
  }


$ docker inspect web.1.2onlllux6w6haprqyjpzyx2fz

"Labels": {
    "com.docker.swarm.node.id": "f0k5s1khmlk9d0fnnbt3fmchx",
    "com.docker.swarm.service.id": "9qmzbansw53tteaocl2uhgf3v",
    "com.docker.swarm.service.name": "web",
    "com.docker.swarm.task": "",
    "com.docker.swarm.task.id": "2onlllux6w6haprqyjpzyx2fz",
    "com.docker.swarm.task.name": "web.1"
}

Or create a new web service now

Metadata

Metadata

Assignees

Labels

area/swarmkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.priority/P3Best effort: those are nice to have / minor issues.version/1.12

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions