What is the difference between docker-compose up and docker-compose start?

前端 未结 2 715
庸人自扰
庸人自扰 2020-12-12 13:05

Whenever I execute

docker-compose start 
docker-compose ps

I see my containers with the state \"UP\". If I do

docker-compos         


        
2条回答
  •  孤城傲影
    2020-12-12 13:40

    In docker Frequently asked questions this is explained very clearly:

    What’s the difference between up, run, and start?

    Typically, you want docker-compose up. Use up to start or restart all the services defined in a docker-compose.yml. In the default “attached” mode, you see all the logs from all the containers. In “detached” mode (-d), Compose exits after starting the containers, but the containers continue to run in the background.

    The docker-compose run command is for running “one-off” or “adhoc” tasks. It requires the service name you want to run and only starts containers for services that the running service depends on. Use run to run tests or perform an administrative task such as removing or adding data to a data volume container. The run command acts like docker run -ti in that it opens an interactive terminal to the container and returns an exit status matching the exit status of the process in the container.

    The docker-compose start command is useful only to restart containers that were previously created, but were stopped. It never creates new containers.

提交回复
热议问题