When refering to your main container, you are probably refering to the project name, which you could usually set via the -p flag. (See other answers)
For docker-compose, you can set the top level variable name to your desired project name.
docker-compose.yml file:
version: "3.9"
name: my-project-name
services:
myService:
...
If you are using Docker Desktop, make sure Use Docker Compose V2 is enabled there.
Related to Docker Compose docs you can set your project name with:
docker-compose -p app up --build
with -p app to set your compose container name to app.
How do I stop docker-compose from adding a suffix and a prefix to container names?
Ability to override folder-based container name prefix
Customizing Container Names in Docker and Docker Compose
Custom container name for docker-compose
Videos
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?