Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set container id when I run docker-compose up?

When I run docker build I can use -t or --tag parameter to deterimne CONTAINER ID.

https://docs.docker.com/engine/reference/commandline/build/

But when I use docker-compose then I cannot find this option.

https://docs.docker.com/compose/reference/up/

I know that docker-composer can create many containers, so maybe there is possibility of set CONTAINER ID in docker-compose.yml? How to do this?

like image 849
Daniel Avatar asked Nov 08 '22 16:11

Daniel


1 Answers

the -t option to docker build doesn't set something called CONTAINER ID. In fact, it has nothing to do with a container. The output of docker build is an image, which is named based on the -t option. docker build -t myorg:myimage . creates an image called myorg:myimage that you can use later to build containers, or push to the docker registry so that you can later use it to build a container.

The equivalent in docker-compose is docker-compose build, not docker-compose up. To specify an image tag in docker-compose build, you use both the build and the image tags on a service in the compose file- in that case, using docker-compose build will build the image based on the build directive, and tag the output using the image tag.

like image 62
Paul Becotte Avatar answered Nov 15 '22 05:11

Paul Becotte