docker-compose run and exec: No container found

后端 未结 3 879
不知归路
不知归路 2021-01-17 12:44

I was trying to open a second terminal un a docker with docker-compose.

First run the container with

docker-compose run my-centos bash
3条回答
  •  梦毁少年i
    2021-01-17 13:32

    docker-compose is meant to run multi-container applications and is supposed to be used with docker-compose up. When you use docker-compose run, you make a special container that's not really meant for normal use.

    Since docker-compose is just a wrapper around docker, you can still access this special container via the normal docker command:

    docker exec docker_my-centos_run_1 bash

    Otherwise I'd suggest start your container with docker-compose up. This makes it so that you can run the second bash in the way that you specified:

    docker-compose exec my-centos bash

    Note: I don't know if you can attach a TTY directly with docker-compose up, so you might need to run an extra docker-compose exec my-centos bash to get two TTYs.

提交回复
热议问题