dockerdocker-compose

Docker Compose container name hex string prefix


I have a Compose project using Compose version 2.27.1, named myproj. Sporadically, when I do an up, I end up with certain container names being prefixed with a random 12-character hexadecimal string (plus underscore).

E.g.

$ docker compose up -d
$ docker ps ...

NAMES
myproj-alpha-1
myproj-beta-1
myproj-gamma-1
d87fed842480_myproj-delta-1   <--- ???
myproj-epsilon-1
myproj-zeta-1

What is that? How can I prevent that?

Docker Compose documentation about this behaviour is non-existent.


Solution

  • I think I finally found the answer. It is implied by the first comment of this bug description:
    https://github.com/docker/compose/issues/3415#issue-153068282

    When we recreate a container we start by renaming the old container by adding the container short id as a prefix. If the start or create fails, the container is left with that prefixed name.

    So the prefix is actually the container id of the former container.