镜像管理

一、什么是镜像


二、搜索镜像的两种方式

2.1 网页搜索

命令搜索

#2.2 以mysql镜像为例
docker search mysql



三、使用国内源命令

由于国外源下载慢,使用国内源加速。

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh-s http://04be47cf.m.daocloud.io

3.1 国内源参考链接

https://www.cnblogs.com/happy4java/p/11206839.html


四、镜像管理命令

PS:ubuntu在云计算领域使用率比较高,我们以ubuntu镜像为例,镜像都是只读的。

4.1 下载乌班图镜像

docker pull ubuntu

4.2 创建一个容器名字为test01使用ubuntu镜像

docker run -itd --name test01 ubuntu 

4.3 查看运行的容器,会出现一串进程ID

docker ps

4.4 进入容器,相当于进入了ubuntu

docker attach test01

4.5 退出容器

ctrl+p+q

4.6 开启容器/停止容器/删除容器

docker start/stop/rm test01

4.7 执行命令到容器里

docker exec test01 ls /home

4.8 查看镜像帮助

docker --help

4.9 查看有关于镜像的命令

docker --help |grep image

4.10 搜索镜像

docker search mysql

4.11 下载镜像

docker pull mysql

4.12 提交镜像到私有仓库或docke hub上

docker push mysql

4.13 查看本地镜像

docker images

4.14 将你更改后的镜像提交为一个新的镜像,self为标签名

docker commit test01 ubuntu:self 

4.15 删除一个镜像,删除前需要停止容器

docker rmi ubuntu

4.16 将容器导出为一个tar包,du -sh 查看大小

docker export test01 > test01.tar 或者
docker save test01 > test01.tar

4.17 将tar包导入为一个镜像

docker import test01.tar ubuntu:self 或者
docker load -i test01.tar

参考链接

猜你喜欢

转载自www.cnblogs.com/tz90/p/12227217.html