Hey tech687, To get faster answers, maybe you should put a bit of efforts into explaining your problem. Like, you know, formatting and such :wink: Now, for what I understand, you just want to change the name of your container. In docker-compose, you can do this by setting the “container_name” prop… Answer from neuroglia on forums.docker.com
🌐
Docker Community
forums.docker.com › general
Custom container name for docker-compose - General - Docker Community Forums
March 19, 2018 - $ cd ~/test $ cat docker-compose.yml version: '3.3’ services: db: image: mysql:5.7 volumes: - dbdata:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress volumes: dbdata: $ docker-comp...
Discussions

How do I stop docker-compose from adding a suffix and a prefix to container names?
If you don't want autogenerated container names, you will need to specify a container name yourself in the compose file: https://docs.docker.com/reference/compose-file/services/#container_name More on reddit.com
🌐 r/selfhosted
13
5
February 24, 2025
Ability to override folder-based container name prefix
/flatscanner /www index.html /api ... docker-compose.yml · To bring up all the services for a service, I go to it's docker directory and up -d, but the prefix is based on the folder, so is always docker_ and I'm getting conflicts as they use similar services: nginx, mysql, redis etc. In order to keep them unique, I need to create another folder inside /docker with the project name so the containers are prefixed ... More on github.com
🌐 github.com
9
February 21, 2016
Customizing Container Names in Docker and Docker Compose
However, for ease of management and better clarity, it’s often useful to override these random names with custom names you assign. This post will guide you through naming containers in both Docker and Docker Compose, replacing the default random names. Naming Containers in Docker When you ... More on community.bigbeartechworld.com
🌐 community.bigbeartechworld.com
0
0
November 29, 2023
Custom container name for docker-compose
Like, you know, formatting and such 😉 Now, for what I understand, you just want to change the name of your container. In docker-compose, you can do this by setting the “container_name” property on any of your containers. For example: db: image: mysql:5.7 container_name: db If you don’t ... More on forums.docker.com
🌐 forums.docker.com
7
0
March 19, 2018
🌐
Docker Docs
docs.docker.com › reference › compose file reference › define services in docker compose
Define services in Docker Compose | Docker Docs
Compose creates a matching entry with the IP address and hostname in the container's network configuration, which means for Linux /etc/hosts get extra lines: 162.242.195.82 somehost 50.31.209.229 otherhost ::1 myhostv6 ... gpus specifies GPU devices to be allocated for container usage. This is equivalent to a device request with an implicit gpu capability. ... group_add specifies additional groups, by name or number, which the user inside the container must be a member of.
🌐
Reddit
reddit.com › r/selfhosted › how do i stop docker-compose from adding a suffix and a prefix to container names?
r/selfhosted on Reddit: How do I stop docker-compose from adding a suffix and a prefix to container names?
February 24, 2025 -

I've been running a stack of services with docker-compose for some time. Today I made a copy of the yaml file, made some edits, and replaced the original. When I bring the stack up using

docker-compose up -d

each container now has a prefix of 'docker_' and a suffix of '_1'. I can't for the life of me get rid of them and they're cluttering up my grafana dashboards which use container names.

How can I use docker-compose without services getting a prefix or suffix?

🌐
GitHub
github.com › docker › compose › issues › 2982
Ability to override folder-based container name prefix · Issue #2982 · docker/compose
February 21, 2016 - /flatscanner /www index.html /api index.php /docker docker-compose.yml /konoro /www index.html /api index.php /docker docker-compose.yml · To bring up all the services for a service, I go to it's docker directory and up -d, but the prefix is based on the folder, so is always docker_ and I'm getting conflicts as they use similar services: nginx, mysql, redis etc. In order to keep them unique, I need to create another folder inside /docker with the project name so the containers are prefixed with the project name instead:
Author   intellix
🌐
IT Playground
blog.it-playground.eu › home › container names and docker-compose
Container names and docker-compose - IT Playground Blog
2 weeks ago - I hope you thought about the same approach as I did – putting all containers to share the same subnet. This way I don’t have to think about bridging or even about bigger things like Swarm. I created a new network on my local docker host · NETWORK ID NAME DRIVER SCOPE 5a712ec0ca4f LAB bridge local · Then I added this network to docker-compose.yml files of both AWX and Netbox projects – those files are provided by the developers and you download them from GitHub as part of the project.
Find elsewhere
🌐
Docker
docs.docker.com › reference › docker compose
docker compose | Docker Docs
Compose sets the project name using the following mechanisms, in order of precedence: ... The top level name: variable from the config file (or the last name: from a series of config files specified using -f) The basename of the project directory ...
🌐
Big Bear Community
community.bigbeartechworld.com › bigbearblog
Customizing Container Names in Docker and Docker Compose - BigBearBlog - Big Bear Community
November 29, 2023 - Docker simplifies the process of managing application processes in containers. By default, Docker assigns a random name to each container you create. However, for ease of management and better clarity, it’s often useful …
🌐
Docker Docs
docs.docker.com › manuals › docker engine › running containers
Running containers | Docker Docs
The UUID identifier is a random ID assigned to the container by the daemon. The daemon generates a random string name for containers automatically. You can also define a custom name using the --name flag.
🌐
Docker Community
forums.docker.com › general
Custom container name for docker-compose - #3 by neuroglia - General - Docker Community Forums
March 19, 2018 - Like, you know, formatting and such 😉 Now, for what I understand, you just want to change the name of your container. In docker-compose, you can do this by setting the “container_name” property on any of your containers. For example: ...
🌐
Docker Community
forums.docker.com › docker engine › compose
Docker compose Confilct default container name already in use - Compose - Docker Community Forums
November 20, 2023 - The container name “/buildx_buildkit_default” is already in use by container “eadcc8e7164bf66380fa38e3ef82b59a08858b6612989260877e17542addd877”. You have to remove (or rename) that container to be able to reuse that name.” for a docker ...
🌐
Docker Docs
docs.docker.com › manuals › docker compose › how compose works
How Compose works | Docker Docs
docker compose ps provides a snapshot of the current state of your services, making it easy to see which containers are running, their status, and the ports they are using: $ docker compose ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS example-frontend-1 example/webapp "nginx -g 'daemon of…" frontend 2 minutes ago Up 2 minutes 0.0.0.0:443->8043/tcp example-backend-1 example/database "docker-entrypoint.s…" backend 2 minutes ago Up 2 minutes
🌐
balenaForums
forums.balena.io › product support › balenaos
Allow to set container name in docker-compose.yml or alternative solution - balenaOS - balenaForums
November 25, 2018 - Hi, It is not possible to set the container name using the container_name field in the docker-compose.yml as is also documented in https://www.balena.io/docs/reference/supervisor/docker-compose/ The actual problem is that a container with each restart or redeployment gets a new container name (e.g. the container name grafana_642983_676605 changes after a restart or redeployment into grafana_643088_676648).
🌐
Docker Community
forums.docker.com › docker hub
How to docker-compose run from container name - Docker Hub - Docker Community Forums
June 17, 2022 - How to docker-compose run from container name my_service: container_name: special_name build: dockerfile: DockerFile This works docker-compose run my_service But this doesn’t. docker-compose run spec…
🌐
Medium
agarwalrounak.medium.com › default-container-names-in-docker-15bdbf56b539
Default container names in Docker | by Rounak Agarwal | Medium
November 15, 2021 - Default container names in Docker When a container is created using Docker, Docker provides a way to name the container using the the --name flag. However, if no name is provided by …
🌐
Baeldung
baeldung.com › home › docker › container hostnames and dns with docker compose
Container Hostnames and DNS with Docker Compose | Baeldung on Ops
April 20, 2025 - Each container gets an IP address and a DNS entry that allows services to refer to each other by name. So, when we define a service in a Docker Compose file, Docker automatically assigns a hostname to the container corresponding to the service name.
🌐
GitHub
github.com › docker › compose › issues › 3722
Docker Compose can't scale containers with hard-coded name · Issue #3722 · docker/compose
July 12, 2016 - You create a docker-compose.yml file in an otherwise empty directory ... Now granted, I understand that a hard-coded container name was specified in the docker-compose.yml file, but shouldn't it still append a unique container number to the end of the container_name property?
Author   pcgeek86
🌐
GitHub
github.com › docker › compose › issues › 6316
The default naming scheme for containers created by Compose · Issue #6316 · docker/compose
November 2, 2018 - The default naming scheme for containers created by Compose in this version has changed from <project>_<service>_<index> to <project>_<service>_<index>_<slug> Is there any way to disable this behavior apart from using container_name in yaml file? We have many scripts that rely on container names and are not using swarm, just a single container stack.
Author   j4r3kb
🌐
Docker Docs
docs.docker.com › reference › compose file reference
Compose file reference | Docker Docs
Want a better editing experience for Compose files in VS Code? Check out the Docker DX extension for linting, code navigation, and vulnerability scanning. Understand version and name attributes for Compose.
🌐
Docker
docs.docker.com › manuals › docker compose › specify a project name
Specify a project name | Docker Docs
By default, Compose assigns the project name based on the name of the directory that contains the Compose file.