I have a server with several lxc containers. In some of the containers there is a docker installed. Usually a docker compose action in these LXC containers results in container names with the format appname_service_1
, e.g. wordpress_app_1
and wordpress_db_1
, when app
and db
are two services which are called in the wordpress
compose file - you know it.
But today i created another LXC container and installed docker in it. The setup is identical to the other containers, thanks to ansible. However, the docker container names are different, e.g. wordpress_db_1_c9de200f9abd
. The hash at the end differs whenever i delete the container and re-create it.
Since this makes containers not so disposable as they should be, because it destroys any routes between the containers, i'd like to know why this hashes are appended at all. All LXC containers have the same docker and the same docker-compose version installed. I'd like to prevent these hashes in my docker container names at all.
Why are they now occuring and didn't occur before?
This is the new behavior from docker-compose and mirrors the behavior of swarm mode. It doesn't impact the ability to connect the containers via the network at all since there are DNS aliases for the service name that are always included, in your case
app
anddb
. There's no need for the full container name to connect to a replica of a service using round-robin DNS.From the release notes:
It's fixed in version 1.23.2: