启动了容器 但是 docker ps 不显示任何容器信息

1.镜像存再

[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    9c7a54a9a43c   6 months ago   13.3kB

2.启动显示成功

[root@localhost ~]# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

3.docker ps 不显示任何容器

[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

4.其实已经启动了,可以使用 docker ps -a

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED          STATUS                      PORTS     NAMES
d42dfd122a05   hello-world   "/hello"   8 minutes ago    Exited (0) 8 minutes ago              ecstatic_ellis
c36527cf3e97   hello-world   "/hello"   11 minutes ago   Exited (0) 11 minutes ago             flamboyant_golick
18edffbcfe86   hello-world   "/hello"   13 minutes ago   Exited (0) 13 minutes ago             kind_wescoff
fcd019613812   hello-world   "/hello"   19 minutes ago   Exited (0) 19 minutes ago             peaceful_kare

5.原因分析
为了理解为什么某个容器看不到,我们需要了解 Dcker 的内部工作原理Docker 使用了-个守护进程(Docker Daemon) 来管理容器和像,当我们使用 docker rur命令来创建一个容器时,实际上是在 Docker 守护进程中创建了一个新的进程,并将其封装到一个容器中.
但是,有时候我们可能会将容器创建在-个不的命名空间 (Namespace) 中命名空间是 Linux 内孩的一人特性,它可以将一组进程及其相关的资源隔离开来,使们在不同的命名空间中运行,互相之间不受影响。Docker 利用命名空间来实现容器之间的隔离。
如果我们在运行容器时使用了一些特珠的参数,例 -re 或 -d,这些参数可能会导致容器创建在一个不同的命名空间中。这就是为什么有时候我们无法看到某个正在运行的容器的原因。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值