简体   繁体   中英

How would one specify which containers to start and not to start in docker-compose? (docker run vs docker create)

In the following guide when establishing how to make data-only docker containers they use the docker create command:

docker create -v /dbdata --name dbdata training/postgres /bin/true

However, as far as I know, with docker-compose you can only run containers not just create them. Is there any way to currently to use docker create in place of docker run for certain containers?

Moreover are there any negative consequences to running a data-only container instead of simply creating it?

Currently the best way seems to be addressed by these two github issue threads:

https://github.com/docker/compose/issues/942
https://github.com/docker/compose/pull/1754

The addition of an option that doesn't run the containers is still under debate, but the solution for now seems to be to manually stop the container after running it

docker-compose <container-name> stop

You can also change the entrypoint in the .yml file to /bin/true if you don't want to deal with manually stopping it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM