Docker镜像的基本操作
文章目录
1. 在官方仓库中查找以下镜像:
Centos :版本7
Ubuntu :版本18.04
Tomcat :版本9.0
Mysql :版本8
docker search centos
docker serach ubuntu
docker search tomcat
docker search mysql
2.下载这些镜像,要求必须下载官方版本
docker pull centos:7
docker pull ubuntu:18.04
docker pull tomcat:9.0
docker pull mysql:8.0

3.查看这些镜像,并注明每一列代表的意义
docker images
REPOSITORY仓库 TAG标签 IMAGEID镜像ID CREATED创建时间 SIZE大小

4.给这些镜像打标签为,全部为latest
docker tag 47067 centos:latest
docker tag 4e502 ubuntu:latest
docker tag 865b1 tomcat:latest
docker tag 0f39f mysql:latest

5.查看这些镜像的历史操作信息
docker history centos
docker history ubuntu
docker history tomcat
docker history mysql

6.删除mysql:latest镜像
docker rmi mysql:latest
7.分别基于容器和模板建立镜像
- 基于容器
docker run -itd centos /bin/bash
docker commit -m 'centos-test' id 镜像名:tag

- 基于模板
docker export id > centos.tar
cat centos.tar | docker import - 镜像名:tag
8.将ubuntu镜像导出,并重新加载
docker save -o ubuntu.tar ubuntu:18.04
docker load -i ubuntu.tar
9.上传镜像
docker login --username=kdl54188 registry.cn-hangzhou.aliyuncs.com
docker tag 5e35e35 registry.cn-hangzhou.aliyuncs.com/loong1996/centos:7
docker push registry.cn-hangzhou.aliyuncs.com/loong1996/centos:7
其它
docker images | awk '!/IMAGE ID/ { print $3 }'
docker rmi $(docker images | awk '{print $3}' | sed 1d) -f