It seems that docker-compose
adds current folder name as a base-name for each created container. So for following directory structure:
/myproj/docker-compose.yml
and docker-compose.yml content:
web: ...
worker: ...
docker-compose will create following containers:
myproj_web_1
myproj_worker_1
I don't mind the suffix (_X
) however I would like to "fix" myproj to some constant like "always_same" so I could move docker-compose.yml file around and still have containers with same names.
How I can do it?
Docker compose uses the Dockerfile if you add the build command to your project's docker-compose. yml. Your Docker workflow should be to build a suitable Dockerfile for each image you wish to create, then use compose to assemble the images using the build command.
Stops containers and removes containers, networks, volumes, and images created by up .
If you want to debug in Docker Compose, run the command Docker Compose Up using one of the two Docker Compose files as described in the previous section, and then attach using the appropriate Attach launch configuration. Launching directly using the normal launch configuration does not use Docker Compose.
To stop this container, press Ctrl+C in the terminal where it was started. Alternatively, you may start a container in detached mode using the -d option. To see all running containers, use the docker ps command.
There are two ways to do this.
Set the environment variable with
export COMPOSE_PROJECT_NAME=foo
or by starting your stack with the -p
switch
docker-compose -p foo build
docker-compose -p foo up
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With