Docker 基础 – 镜像

Docker 基础 – 镜像

温馨提示:本文最后更新于2024-11-29 13:50:35,某些文章具有时效性,若有错误或已失效,请在下方留言

镜像的获取

镜像的获取
镜像的获取

镜像的获取大致有三种方式:

  1. Registry 中拉取
  2. Dockerfile 构建
  3. 文件导入

镜像基本操作

查看镜像

$ docker image ls
REPOSITORY                  TAG         IMAGE ID       CREATED         SIZE
postgres                    15-alpine   c558f49f952d   3 days ago      256MB
langgenius/dify-web         0.11.2      20bd31965900   6 days ago      347MB
langgenius/dify-api         0.11.2      ec932056c6a7   6 days ago      3.03GB
langgenius/dify-sandbox     0.2.10      e09eb1619e46   5 weeks ago     626MB
redis                       6-alpine    cdabd876a000   7 weeks ago     37MB
nginx                       latest      7a3f95c07812   7 weeks ago     197MB
ubuntu/squid                latest      e830c46c0231   2 months ago    288MB
semitechnologies/weaviate   1.19.0      b7fde6d5a98e   19 months ago   51MB

拉取镜像

镜像的拉取操作,以nginx 为例

# 拉取最新版本的镜像
$ docker pull nginx

# 拉取固定版本的镜像
$ docker pull nginx:1.20.0

镜像详情

# 查看镜像更多的详细信息
$ docker image inspect c316d5a335a5<镜像 ID>

删除镜像

# 删除镜像文件,正在运行的镜像程序是无法删除的。
$ docker image rm c316d5a335a5<镜像 ID>

镜像导入导出

导出镜像

# 将镜像文件导出
docker image save <name/镜像 ID> -o <导出的镜像名称>

# 示例
docker image save langgenius/dify-web -o /root/images/dify-web.image
docker image save langgenius/dify-api -o /root/images/dify-api.image
docker image save langgenius/dify-sandbox -o /root/images/dify-sandbox.image
docker image save postgres -o /root/images/postgres.image
docker image save redis -o /root/images/redis.image
docker image save nginx -o /root/images/nginx.image
docker image save ubuntu/squid -o /root/images/squid.image
docker image save semitechnologies/weaviate -o /root/images/weaviate.image

导入镜像

# docker 镜像文件的导入
docker image load -i <导入的镜像名称>

# 示例(Linux服务器)
docker image load -i ./dify-api.image
docker image load -i ./dify-sandbox.image 
docker image load -i ./dify-web.image
docker image load -i ./nginx.image
docker image load -i ./postgres.image
docker image load -i ./redis.image
docker image load -i ./squid.image
docker image load -i ./weaviate.image 
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容