I'm using Docker Compose V3 in a project, however when I run
docker compose up -d
in the Docker client app is displayed the name of the folder inside which it's located the docker-compose.yml
file...
For this reason, I've looked for something like a container_name
but for the whole project, not only for a single container, and I'm unable to find it
Furthermore, if not looking at the examples, there is no reference to a "general structure" of the docker-compose.yml
file, something like a DTD for XML
I know that there is no way to create that DTD because at some point, keys and values depends on the containers, but at least for the first 3/4 layer of depth maybe there is a way or it's reported somewhere (somewhere that I'm not able to find)
So my question is, is there an alternative for container_name
for the whole docker-compose.yml
? Are there any DTD for the docker-compose.yml
?
Docker works with services (containers) therefore Docker engine generate a unique ID and a more-readably name for every containers. In default case the 1st part of the container name is the directory name where is the docker-compose.yml file found and the second part is the service name which you defined in the docker-compose.yml file.
As Lucas Bazetto wrote you can override the 1st part of the containers name with the COMPOSE_PROJECT_NAME=example_container_name_prefix option in the .env file.