docker镜像管理

1.查看镜像

[root@centos201 ~]# docker image ls # 查看现有的镜像列表。
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 20 months ago 13.3kB
[root@centos201 ~]#
[root@centos201 ~]#
[root@centos201 ~]# docker image ls -q # 只查看镜像的id
feb5d9fea6a5
[root@centos201 ~]#
[root@centos201 ~]# docker images # 等效于"docker image ls"
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 20 months ago 13.3kB
[root@centos201 ~]#

2.给镜像打标签

[root@centos201 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 20 months ago 13.3kB
[root@centos201 ~]#
[root@centos201 ~]# docker image tag hello-world centos-hello-world:v0.1
[root@centos201 ~]#
[root@centos201 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 20 months ago 13.3kB
centos-hello-world v0.1 feb5d9fea6a5 20 months ago 13.3kB
[root@centos201 ~]#

3.本地镜像迁移

3.1.导出镜像到一个tar包的2种方式

导出镜像到一个tar包的2种方式:
[root@centos201 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 20 months ago 13.3kB
test-hello-world v0.1 feb5d9fea6a5 20 months ago 13.3kB
[root@centos201 ~]#
[root@centos201 ~]# docker image save test-hello-world:v0.1 > test-docker-hello-world.tar.gz
[root@centos201 ~]#
[root@centos201 ~]# docker image save --output test-docker-hello-world-v2.tar.gz test-hello-world:v0.1

3.2.从一个tar包导入镜像的两种方式

[21:24:47 root@centos202 ~]#scp * 10.0.0.211:~
root@ubuntu211:~# docker image load < oldboyedu-docker-hello-world-v2.tar.gz
root@ubuntu211:~#
root@ubuntu211:~# docker image load -i oldboyedu-docker-hello-world-v2.tar.gz

4.下载镜像

[root@centos201 ~]# docker pull nginx:1.14.2 # 下载一个nginx版本号为1.14.2的镜像。
[root@centos201 ~]# docker pull mysql:8.0 # 下载一个mysql版本号为8.0的镜像。
[root@centos201 ~]# docker pull docker.elastic.co/elasticsearch/elasticsearch:7.17.5 # 去第三方镜像仓库下载镜像
[root@centos201 ~]# docker pull tomcat:9 # 下载一个tomcat9的镜像

5.删除镜像

[root@centos201 ~]# docker image rm hello-world # 删除指定的镜像的名称。
root@ubuntu211:~# docker image rm -f feb5d9fea6a5 # 基于镜像ID强制删除镜像,尽管该镜像被其他镜像或容器引用。
[root@centos202 ~]# docker image rm -f `docker image ls -q` # 删除本地的所有镜像。
posted @   只为心情愉悦  阅读(14)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示