Docker镜像管理

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、下载镜像

docker pull [image_name]

3.3、上传镜像

docker push [image_name]

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

 

posted @   小粉优化大师  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示