[root@localhost /]# docker search centos|head -3 #搜索镜像
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 4754 [OK][root@localhost /]# docker pull centos #下载镜像
Using default tag: latest.............
Digest: sha256:6f6d986d425aeabdc3a02cb61c02abb2e78e57357e92417d6d58332856024faf
Status: Downloaded newer image for centos:latest
[root@localhost /]# docker images #查看镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5182e96772bf 7 weeks ago 200MB
[root@iZm5e3hwzuo58e05kxjiifZ rc.d]# docker ps -a #查看所有创建的容器包括已经停止的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
70e151cd2766 centos "/bin/bash" 7 seconds ago Exited (0) 5 seconds ago zealous_mclean
dfdf33852d47 centos "/bin/bash" 20 seconds ago Up 19 seconds frosty_saha
[root@iZm5e3hwzuo58e05kxjiifZ rc.d]# docker ps #查看所有运行的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dfdf33852d47 centos "/bin/bash" 22 seconds ago Up 21 seconds frosty_saha
[root@iZm5e3hwzuo58e05kxjiifZ rc.d]# docker ps -l #查看最新创建的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
70e151cd2766 centos "/bin/bash" 29 minutes ago Exited (0) 29 minutes ago
docker 利用已存在的容器创建一个镜像(Dockerfile构建镜像略)
-a #提交的镜像作者
-c #使用Dockerfile指令来创建镜像
-m #提交时附上说明文字
-p #在commit时,将容器暂停
-------------------------------------------------------------------------------------------
[root@iZm5e3hwzuo58e05kxjiifZ ~]# docker commit -a "王云龙" -m "创建的新镜像" redis wyl5588redis-test
sha256:9c2d2fc6e09cb35543fbb2467db90e741dc6b7daabab83924534bcfe6641bbe2
[root@iZm5e3hwzuo58e05kxjiifZ ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wyl5588redis-test latest 9c2d2fc6e09c 3 seconds ago 83.4MB
docker 修改镜像标签,并推送
[root@iZm5e3hwzuo58e05kxjiifZ Dockerfile]# docker tag centos 192.168.8.88:5000/centos:v1.0 #给centos镜像打一个行的tag[root@iZm5e3hwzuo58e05kxjiifZ Dockerfile]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.8.88:5000/centos v1.0 5182e96772bf 7 weeks ago 200MB
centos latest 5182e96772bf 7 weeks ago 200MB
[root@iZm5e3hwzuo58e05kxjiifZ Dockerfile]#docker push 192.168.8.88:5000/centos:v1.0 #将本地docker中的镜像推送到镜像仓库中