How to continue a Docker container which has exited

前端 未结 10 1906
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 14:51

Consider:

docker run -it centos /bin/bash

I pressed Ctrl+D to exit it.

I wa

相关标签:
10条回答
  • 2020-11-29 15:14

    These commands will work for any container (not only last exited ones). This way will work even after your system has rebooted. To do so, these commands will use "container id".

    Steps:

    1. List all dockers by using this command and note the container id of the container you want to restart: docker ps -a

    2. Start your container using container id: docker start <container_id>

    3. Attach and run your container: docker attach <container_id>

    NOTE: Works on linux

    0 讨论(0)
  • 2020-11-29 15:15

    Follow these steps:

    1. Run below command to see that all the container services both running and stopped on. Option -a is given to see that the container stops as well

      docker ps -a
      
    2. Then start the docker container either by container_id or container tag names

      docker start <CONTAINER_ID> or <NAMES>
      

      Say from the above picture, container id 4b161b302337
      So command to be run is

      docker start 4b161b302337
      
    3. One can verify whether the container is running with

      docker ps
      
    0 讨论(0)
  • 2020-11-29 15:16
    docker start `docker ps -a | awk '{print $1}'`
    

    This will start up all the containers that are in the 'Exited' state

    0 讨论(0)
  • 2020-11-29 15:19

    If you want to continue exactly one Docker container with a known name:

    docker start  `docker ps -a -q --filter "name=elas"`
    
    0 讨论(0)
提交回复
热议问题