When I set up a couple of Docker containers in docker-compose.yaml
file with links, the name of the containers ends up being of the format prefix_%s_1
That's just how docker-compose names containers so that it can manage them.
The basename is the name of the directory containing the docker-compose.yaml
file. This is followed by the name of the container as specified in your docker-compose.yaml
file, and finally that is followed by an instance number which increases if you bring up multiple instances of a container using something like docker-compose scale
.
This naming scheme is how docker-compose is able to identify your containers when you attempt to operate on them using something like docker-compose stop
.
I don't think this conflicts with the documentation in any way. That is, if I start with, say, this docker-compose.yaml
in a directory named sotest
:
irc:
image: docker.io/xena/elemental-ircd
links:
- web
web:
image: larsks/thttpd
And then bring up the compose:
$ docker-compose up
I get two containers:
CONTAINER ID IMAGE ...NAMES
960c1491c03e docker.io/xena/elemental-ircd ...sotest_irc_1
422bba313e71 larsks/thttpd ...sotest_web_1
If I look at the /etc/hosts
file inside of sotest_irc_1
, I see:
172.17.0.28 web 422bba313e71 sotest_web_1
In addition to a number of other names. So the linked host is available by name as described in the docs.