Docker安装CentOS遇到的问题
刚接触docker这里记录下安装CentOS时遇到的坑, 首先docker pull learn测试试了echo hello world正常, 然后想pull个CentOS测试下, 解决就报了下面这条错误 [root@beta-enze ~]# docker pull centosUsing default tag: latestTrying to pull repository docker.
刚接触docker这里记录下安装CentOS时遇到的坑, 首先docker pull learn测试试了echo hello world正常, 然后想pull个CentOS测试下, 解决就报了下面这条错误
[root@beta-enze ~]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ... Repository docker.io/library/centos already being pulled by another client. Waiting.
首先我尝试了rmi关闭image
docker rmi ed9c93747fe1
报错提示无法删除
这是因为由于image被某个container引用(拿来运行),如果不将这个引用的container销毁(删除),那image肯定是不能被删除, 所以想要删除运行过的images必须首先删除它的container。
查看所有container
docker ps -a
[root@beta-enze ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
183c7f52ac5d learn/ping "apt-get install -y p" 17 hours ago Exited (0) 17 hours ago prickly_visvesvaraya
b7f91251b6bc learn/ping "ping www.baidu.com" 17 hours ago Exited (0) 17 hours ago prickly_raman
f7750030e2ba learn/tutorial "apt-get install -y p" 17 hours ago Exited (0) 17 hours ago modest_lovelace
525f101d4436 learn/tutorial "ping www.baidu.com" 17 hours ago Created stupefied_wilson
710c8678fc9b learn/tutorial "echo jfjkalkfl" 17 hours ago Exited (0) 17 hours ago naughty_lumiere
acff090861c1 hello-world "/hello" 18 hours ago Exited (0) 18 hours ago lonely_bell
4e1ea738a0e2 hello-world "/hello" 18 hours ago Exited (0) 18 hours ago gloomy_goldstine
这里可以查看所有已关闭和未关闭的container,删除它:
[root@beta-enze ~]# docker rm 183c7f52ac5d
183c7f52ac5d
然后就可以rmi所有image了, 可是关完之后发现有一个无法关闭
[root@beta-enze ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 168a69b62202 5 weeks ago 172.3 MB
尝试和很多种方法都没法删除,暂时不管他了
重启docker
[root@beta-enze ~]# service docker restart
[root@beta-enze ~]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ... latest: Pulling from library/centos
812e9d9d677f: Pull complete
4234bfdd88f8: Pull complete
ce20c473cd8a: Pull complete
47d44cb6f252: Already exists
168a69b62202: Already exists
Digest: sha256:c96eeb93f2590858b9e1396e808d817fa0ba4076c68b59395445cb957b524408
Status: Downloaded newer image for docker.io/centos:latest
发现成功了!
这是查看image
[root@beta-enze ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.io/centos latest ce20c473cd8a 5 weeks ago 172.3 MB
发现之前那个空的tag的image没了取而代之的是新的CentOS, echo “hello world”成功所以猜测 之前无法删除的那个空的image应该是之前尝试pull CentOS成功下载的部分 service docker restart后成功下载后半部分然后这个image镜像就完整了.
嗯, 最后理下思路, 前面尝试rm/rmi删除container和image的思路是错的, service docker restart就OK, 可能有偏见或者错误的地方, 欢迎大家指出,我也会在理解更透彻之后更新这篇文章.
更多推荐
所有评论(0)