理解docker镜像
镜像是用来启动容器的只读模板,是容器启动所需要的rootfs,类似于虚拟机所使用的镜像。
列出本机镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest 020584afccce 7 days ago 1.22MB
[root@localhost ~]# docker images --help
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
List images
Options:
-a, --all Show all images (default hides intermediate images) #列出所有镜像(默认是隐藏中间镜像)
--digests Show digests #列出镜像摘要。
-f, --filter filter Filter output based on conditions provided #条件过滤输出。
--format string Pretty-print images using a Go template #使用GO模板打印。
--no-trunc Don't truncate output #不截断输出。
-q, --quiet Only show numeric IDs #仅显示数字标识。
下载镜像
[root@localhost ~]# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
Digest: sha256:1303dbf110c57f3edf68d9f5a16c082ec06c4cf7604831669faf2c712260b5a0
Status: Image is up to date for busybox:latest
docker.io/library/busybox:latest
导入导出镜像
[root@localhost ~]# docker save -o busybox.tar busybox
[root@localhost ~]# docker load -i busybox.tar
Loaded image: busybox:latest
运行镜像为容器
[root@localhost ~]# docker run busybox:latest