查看当前镜像
[root@ztydl ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos-wget latest 9e694366ecc0 29 minutes ago 312.9 MB
centos latest 1c1b67b33c28 3 weeks ago 196.6 MB
daocloud.io/centos 7 1c1b67b33c28 3 weeks ago 196.6 MB
zty latest 32e90b4dd628 3 weeks ago 108.3 MB
daocloud.io/daocloud/daocloud-toolset latest 2a2ecdfa41dc 6 months ago 147.1 MB
根据镜像ID删除镜像(-f force 强行删除)
[root@ztydl ~]# docker rmi 32e90b4dd628
Error response from daemon: Conflict, cannot delete image 32e90b4dd628 because it is tagged in multiple repositories, use -f to force
Error: failed to remove images: [32e90b4dd628]
搜索docker镜像
[root@ztydl ~]# docker search nginx
根据镜像名下载 镜像
[root@ztydl ~]# docker pull nginx
根据镜像ID给镜像打标签
[root@ztydl ~]# docker tag 1c1 centos
运行docker镜像
[root@ztydl ~]# docker run -it centos /bin/bash
[root@ac14ee1c187c /]# ls
anaconda-post.log dev home lib64 media opt root sbin sys usr
bin etc lib lost+found mnt proc run srv tmp var
查看正在运行的容器
[root@ztydl ~]# docker ps
查看左右容器
[root@ztydl ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ac14ee1c187c centos "/bin/bash" 18 seconds ago Exited (0) 8 seconds ago berserk_curie
使用指定镜像 运行容器
[root@ztydl ~]# docker run -it --name vm1 centos bash
-d: 后台运行容器,并返回容器ID;
-i: 以交互模式运行容器,通常与 -t 同时使用;
-t: 为容器重新分配一个伪输入终端,通常与 -i 同时使用;
--name="nginx-lb": 为容器指定一个名称;
将正在运行的已做修改的 容器 生成新的镜像
[root@ztydl ~]# docker commit -m "test asd" -a "ztyzty" 311ad zty-centos
50be09cb7fbc575053e73772f9af7fdbf89c65d993120462d8c56b73b0c3d7f4
[root@ztydl ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
zty-centos latest 50be09cb7fbc 15 seconds ago 198.3 MB
将已有镜像保存为本地文件
[root@ztydl ~]# docker save -o zty-centos.tar.gz zty-centos
[root@ztydl ~]# docker load < zty-centos.tar.gz
使用本地模板 导入镜像
[root@ztydl ~]# cat zty-centos.tar.gz |docker import - import_os
d83c7b9794a3e1ae88ff8093c4103fbbec34941f917ea1e890bf5b8c84e31729