[英]docker start <container ID> doesn't do anything
If I spin up a Docker container with:如果我使用以下命令启动 Docker 容器:
docker run -it ubuntu /bin/bash
and then exit.然后退出。 I can see the container using
我可以看到容器使用
docker ps -a
However, if I try and restart the container with但是,如果我尝试重新启动容器
docker start <container ID>
I just get echoed back and returned to the command prompt.我只是得到回声并返回到命令提示符。
What am I missing?我错过了什么?
After running docker start <container ID>
to restart the container try running a docker ps
to ensure it's actually running.运行
docker start <container ID>
重新启动容器后,尝试运行docker ps
以确保它实际运行。
If it IS running and you want to run commands on a bash shell from within the container, you can run the below command.如果它正在运行并且您想从容器内在 bash shell 上运行命令,则可以运行以下命令。 In your case it would be :
在您的情况下,它将是:
docker exec -it <container ID> bash
use docker start with '-ai' so it attaches to container interactively使用带“-ai”的 docker start 以交互方式附加到容器
docker start -ai <container ID>
CAUTION!注意! This will relaunch the process that this container is supposed to run:
这将重新启动该容器应该运行的进程:
CMD
instruction, then it will run it.CMD
指令的 Dockerfile 定义的,那么它将运行它。你可以试试:
docker start <container name>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.