docker
and docker-compose
seem to be interacting with the same dockerFile, what is the difference between the two tools?
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
docker
manages single containersdocker-compose
manages multiple container applicationsUsage of docker-compose requires 3 steps:
docker-compose up
to start and run appBelow is a docker-compose.yml example taken from the docker docs:
The
docker
cli is used when managing individual containers on a docker engine. It is the client command line to access the docker daemon api.The
docker-compose
cli can be used to manage a multi-container application. It also moves many of the options you would enter on thedocker run
cli into thedocker-compose.yml
file for easier reuse. It works as a front end "script" on top of the same docker api used bydocker
, so you can do everythingdocker-compose
does withdocker
commands and a lot of shell scripting. See this documentation on docker-compose for more details.Update for Swarm Mode
Since this answer was posted, docker has added a second use of docker-compose.yml files. Starting with the version 3 yml format and docker 1.13, you can use the yml with docker-compose and also to define a stack in docker's swarm mode. To do the latter you need to use
docker stack deploy -c docker-compose.yml $stack_name
instead ofdocker-compose up
and then manage the stack withdocker
commands instead ofdocker-compose
commands. The mapping is a one for one between the two uses:For more details on swarm mode, see docker's swarm mode documentation.