1、什么是镜像
它是一个只读的文件,就类似于我们安装操作系统时候所需要的那个iso光盘镜像,通过运行这个镜像来完成各种应用的部署。
这里的镜像就是一个能被docker运行起来的一个程序。
2、镜像相关命令
]# docker --help | grep image
run Create and run a new container from an image
build Build an image from a Dockerfile
pull Download an image from a registry
push Upload an image to a registry
images List images
search Search Docker Hub for images
image Manage images
manifest Manage Docker image manifests and manifest lists
trust Manage trust on Docker images
commit Create a new image from a container's changes
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
load Load an image from a tar archive or STDIN
rmi Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
3、镜像命令实战
3.1、搜索镜像
docker search [image_name]
3.2、下载镜像
3.3、上传镜像
3.4、查看镜像
docker images <image_name>
3.5、历史镜像
docker history [image_name]
3.6、镜像打标签
docker tag [old_image]:[old_version] [new_image]:[new_version]
3.7、删除镜像
docker rmi [image_id/image_name:image_version]
3.8、导出镜像
docker save -o [包文件] [镜像]
示例
# 非压缩导出
docker save -o hello-word.tar hello-world
# 压缩导出
docker save hello-world:latest | gzip >hello-world.tar.gz
3.9、导入镜像
docker load < [image.tar_name]
示例
# 非压缩导入
docker load < hello-word.tar
# 压缩导入
gunzip -c hello-world.tar.gz | docker load