Should I use docker-compose up or run?

后端 未结 3 820
轻奢々
轻奢々 2020-12-22 20:46

Is there a reason to use run to start up a docker-compose.yml file or should you just use up?

I understand that run

3条回答
  •  -上瘾入骨i
    2020-12-22 21:27

    There is an answer from docker docs.

    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.

提交回复
热议问题