Suppose I launched a container like this:

docker run -ti my_super_images bash

After some time, I enter the exit and exit it. Now information about it is contained only in docker ps -a . How do I log in to the container terminal again, knowing its id?

    2 answers 2

    The example specified in the adjacent response will work to enter the working container and start an additional process, but will not do anything with the process stopped, as described in the task.

     docker run -ti --name test-subject ubuntu root@6d7a294a9450:/# exit --- docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6d7a294a9450 ubuntu "/bin/bash" 2 minutes ago Exited (0) About a minute ago test-subject --- docker exec -ti test-subject bash Error response from daemon: Container 6d7a294a9450b81420c8cf25357a580c3f05f25fae5bc03e890d9b5737c1b266 is not running 

    In order to enter a stopped one, you must first start it.

     docker start test-subject 

    In this particular case, the container will be released immediately, because its main process is bash, which cannot read STDIN and has not received a command, and in this case it is of interest to cling to the main process rather than launch another process in the container. Therefore, it is necessary to directly indicate the docker, that it is necessary to hook STDIN to the process that will be started via start:

     docker start -ia test-subject root@6d7a294a9450:/# 

    voila

       docker exec -ti имя_контейнера bash 

      you can log in as a user with the -user user_name directive

      • Error response from daemon: Container 6d7a294a9450b81420c8cf25357a580c3f05f25fae5bc03e890d9b5737c1b266 is not running ¯_ (ツ) _ / ¯ - etki