我下载了在后台作为守护进程执行的centos基础镜像,然后累了进不了终端,进不去。
我的主机是 Ubuntu 16.04。
以下是我执行的步骤:
主机操作系统版本 Ubuntu16.04
root@jim-Ubuntu1504:/home/jim/web# lsb_release -a No LSB modules are
available. Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS
Release: 16.04 Codename: xenial
root@jim-Ubuntu1504:/home/jim/web#
Run Code Online (Sandbox Code Playgroud)
通过以下命令启动docker
root@jim-Ubuntu1504:/home/jim/web# docker run -d --name=my_centos centos
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
a3ed95caeb02: Pull complete
da71393503ec: Pull complete
Digest: sha256:1a62cd7c773dd5c6cf08e2e28596f6fcc99bd97e38c9b324163e0da90ed27562
Status: Downloaded newer image for centos:latest
63f4b8fce1bd44253bb420436da3ad5b8f532b253fc9e74ff52ad1b2f9844251
root@jim-Ubuntu1504:/home/jim/web# docker exec -i -t my_centos bash
Error response from daemon: Container 63f4b8fce1bd44253bb420436da3ad5b8f532b253fc9e74ff52ad1b2f9844251 is not running
Run Code Online (Sandbox Code Playgroud)
不知道为什么要退出
root@jim-Ubuntu1504:/home/jim/web# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
63f4b8fce1bd centos "/bin/bash" 18 minutes ago Exited (0) 18 minutes ago my_centos
f0ca8b9f4fa5 nginx "nginx -g 'daemon off" 23 minutes ago Up 23 minutes 80/tcp, 443/tcp my_nginxtemp
bb9ab4958c33 nginx "nginx -g 'daemon off" About an hour ago Up About an hour 80/tcp, 443/tcp boring_aryabhata
886d174f641d nginx "nginx -g 'daemon off" 2 hours ago Up 2 hours 80/tcp, 443/tcp mad_fermat
root@jim-Ubuntu1504:/home/jim/web#
Run Code Online (Sandbox Code Playgroud)
启动了容器但不知道它为什么退出
root@jim-Ubuntu1504:/home/jim/web# docker start 63f4b8fce1bd
63f4b8fce1bd
root@jim-Ubuntu1504:/home/jim/web# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
63f4b8fce1bd centos "/bin/bash" 26 minutes ago Exited (0) 2 seconds ago my_centos
f0ca8b9f4fa5 nginx "nginx -g 'daemon off" 30 minutes ago Up 30 minutes 80/tcp, 443/tcp my_nginxtemp
bb9ab4958c33 nginx "nginx -g 'daemon off" About an hour ago Up About an hour 80/tcp, 443/tcp boring_aryabhata
886d174f641d nginx "nginx -g 'daemon off" 2 hours ago Up 2 hours 80/tcp, 443/tcp mad_fermat
root@jim-Ubuntu1504:/home/jim/web# docker exec -i -t my_centos bash
Error response from daemon: Container 63f4b8fce1bd44253bb420436da3ad5b8f532b253fc9e74ff52ad1b2f9844251 is not running
root@jim-Ubuntu1504:/home/jim/web#
Run Code Online (Sandbox Code Playgroud)
PS: Can someone disable the restriction to post once every 90 mins ??? Learning has to be spontaneous and interactive.
如果你查看 CentOS 最新镜像的 Dockerfile,你会注意到最后一行:
CMD ["/bin/bash"]
因此,您启动了一个具有外壳的容器,它存在,仅此而已。
尝试:
docker run -it --name=my_centos centos sleep infinity
或任何变体。
顺便说一句,当你这样做时
root@jim-Ubuntu1504:/home/jim/web# docker exec -i -t my_centos bash
您假设您的容器正在运行,但这里没有运行。
检查:
docker ps -a --filter="name=my_centos"
您的容器已启动。
| 归档时间: |
|
| 查看次数: |
3226 次 |
| 最近记录: |