搜索镜像
[root@docker01 ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 12673 [OK]
jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 1742 [OK]
查看镜像
[root@docker01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 2073e0bcb60e 2 weeks ago 127MB
[root@docker01 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 2073e0bcb60e 2 weeks ago 127MB
导出镜像
[root@docker01 ~]# docker image save nginx:latest -o nginx.tar.gz
[root@docker01 ~]# ll
total 226836
-rw-------. 1 root root 1448 Aug 9 2018 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Feb 20 10:40 docker_rpm
-rw-r--r-- 1 root root 101719024 Feb 20 10:40 docker_rpm.tar.gz
-rw------- 1 root root 130548224 Feb 20 11:53 nginx.tar.gz
[root@docker01 ~]# scp nginx.tar.gz 192.168.1.2:/root
root@192.168.1.2's password:
nginx.tar.gz 100% 125MB 97.6MB/s 00:01
导入镜像
[root@docker02 ~]# ll
total 226836
-rw-------. 1 root root 1448 Aug 9 2018 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Feb 20 10:40 docker_rpm
-rw-r--r-- 1 root root 101719024 Feb 20 10:49 docker_rpm.tar.gz
-rw------- 1 root root 130548224 Feb 20 11:53 nginx.tar.gz
[root@docker02 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@docker02 ~]# docker image load -i nginx.tar.gz
488dfecc21b1: Loading layer 72.48MB/72.48MB
b4a29beac87c: Loading layer 58.04MB/58.04MB
22439467ad99: Loading layer 3.584kB/3.584kB
Loaded image: nginx:latest
[root@docker02 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 2073e0bcb60e 2 weeks ago 127MB
import 导入之后没有名称和版本
[root@docker02 ~]# docker image import nginx.tar.gz
sha256:58a06c5769f770f0be8543d237cc7b4269578e2a7327072fe80001e6886fef24
[root@docker02 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 58a06c5769f7 4 seconds ago 131MB
打标签
[root@docker02 ~]# docker image tag 58a06c5769f7 nginx:latest
[root@docker02 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 58a06c5769f7 2 minutes ago 131MB
删除镜像
[root@docker01 ~]# docker image rm nginx:latest
Untagged: nginx:latest
Deleted: sha256:2073e0bcb60ee98548d313ead5eacbfe16d9054f8800a32bedd859922a99a6e1
Deleted: sha256:a3136fbf38691346715cac8360bcdfca0fff812cede416469653670f04e2cab0
Deleted: sha256:99360ffcb2da18fd9ede194efaf5d4b90e7aee99f45737e918113e6833dcf278
Deleted: sha256:488dfecc21b1bc607e09368d2791cb784cf8c4ec5c05d2952b045b3e0f8cc01e
[root@docker01 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
清理无效文件
没有版本的
docker image prune
长格式与短格式
docker search 搜索镜像,优先选择官方,start数量多.
docker image pull == docker pull 下载镜像
docker image push == docker push 上传镜像
docker image save == docker save 导出镜像
docker image load == docker load 导入镜像
docker image ls == docker images 查看镜像列表
docker image rm == docker rmi 删除镜像
docker image tag == docker tag 给镜像打标签
docker image inspect == docker inspect 查看属性
docker image prune == docker prune 清理无效文件