简体   繁体   中英

How to start the stopped ubuntu container in docker? (ran without options (-i - t) )

How to start the stopped ubuntu container in docker? any idea?

$docker pull ubuntu

$docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

ubuntu latest 7698f282e524 29 hours ago 69.9MB

$docker run ubuntu

$docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

512009f5b00e ubuntu "/bin/bash" 39 minutes ago Exited (0) About a minute ago sad_noether

$docker start sad_noether

sad_noether

$docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

$docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

512009f5b00e ubuntu "/bin/bash" 40 minutes ago Exited (0) 23 seconds ago sad_noether

$docker exec -it sad_noether bash

Error response from daemon: Container 512009f5b00e6be5e3ee199d2db25c628219c237b16e37eed5cb6052179ebdbc is not running

How to start the stopped ubuntu container in docker?

docker start CONTAINER

In your case, you ran ubuntu without any foreground process, so the container exits immediately when you start it.

You should run docker run -it ubuntu bash

您应该运行它以保持容器运行。

docker run -d ubuntu sleep 9999999
  1. docker run -it centos /bin/bash to run the container the first time and exit.
  2. docker ps -a to see that container is stopped.
  3. docker start -ai [CONTAINER_ID] to start the existing container.
  4. You are into the container!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM