镜像管理
Posted tz90
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了镜像管理相关的知识,希望对你有一定的参考价值。
一、搜索镜像的两种方式
1.1网页搜索
https://hub.docker.com/search?q=&type=image
1.2 命令搜索
二、使用国内源加速
由于国外源下载慢,使用国内源加速。
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://04be47cf.m.daocloud.io
其余方式参考:
https://www.cnblogs.com/happy4java/p/11206839.html
三、镜像管理命令
3.1 获取镜像
1.不指定TAG标签默认选择latest标签就会下载最新镜像,镜像内容会随着最新版本变更而变化,生产环境中需要指定标签。
[root@localhost ~]# docker pull ubuntu:18.04 18.04: Pulling from library/ubuntu Image docker.io/library/ubuntu:18.04 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ 5c939e3a4d10: Already exists c63719cdbe7a: Already exists 19a861ea6baf: Already exists 651c9d2d6c4f: Already exists Digest: sha256:f7addb415fe10cac22288733482875be44e65cc7b913de0a6c0ec0b5fde01ccd
2.从非官方仓库下载需要指定完整的仓库地址。
PS:知道有这命令就好,报错不重要,有什么问题憋着
[root@localhost ~]# docker pull hub.c.163.com/public/ubuntu:18.04
Error response from daemon: manifest for hub.c.163.com/public/ubuntu:18.04 not found: manifest unknown: manifest unknown
3.下完后,利用镜像创建容器,运行bash命令执行打印Hello World
[root@localhost ~]# docker run -it ubuntu:18.04 bash WARNING: IPv4 forwarding is disabled. Networking will not work. root@e31da7f941d5:/# echo "Hello World" Hello World root@e31da7f941d5:/# exit exit
3.2 查看镜像信息
images命令
[root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 18.04 ccc6e87d482b 9 days ago 64.2MB mysql latest 3a5e53f63281 10 days ago 465MB hello-world latest fce289e99eb9 12 months ago 1.84kB [root@localhost ~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 18.04 ccc6e87d482b 9 days ago 64.2MB mysql latest 3a5e53f63281 10 days ago 465MB hello-world latest fce289e99eb9 12 months ago 1.84kB
images子命令
列出所有镜像文件,默认否
[root@localhost ~]# docker images --all=true REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 18.04 ccc6e87d482b 9 days ago 64.2MB mysql latest 3a5e53f63281 10 days ago 465MB hello-world latest fce289e99eb9 12 months ago 1.84kB
列出镜像数字摘要值,默认否
[root@localhost ~]# docker images --digests=true REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE ubuntu 18.04 sha256:8d31dad0c58f552e890d68bbfb735588b6b820a46e459672d96e585871acc110 ccc6e87d482b 9 days ago 64.2MB ubuntu 18.04 sha256:f7addb415fe10cac22288733482875be44e65cc7b913de0a6c0ec0b5fde01ccd ccc6e87d482b 9 days ago 64.2MB mysql latest sha256:f1df505c4c6e8eae599a0482e3bde3e761cd700c00cbc371a8161648a26817c0 3a5e53f63281 10 days ago 465MB hello-world latest sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f fce289e99eb9 12 months ago 1.84kB
过滤列出的镜像,如dangling=true只显示没有被使用的镜像
[root@localhost ~]# docker images --filter=dangling=true REPOSITORY TAG IMAGE ID CREATED SIZE
对输入结果中太长的部分是否进行截断,默认是
仅输出ID信息,默认否
[root@localhost ~]# docker images -q=true ccc6e87d482b 3a5e53f63281 fce289e99eb9 [root@localhost ~]# docker images -q=false REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 18.04 ccc6e87d482b 9 days ago 64.2MB mysql latest 3a5e53f63281 10 days ago 465MB hello-world latest fce289e99eb9 12 months ago 1.84kB
以上是关于镜像管理的主要内容,如果未能解决你的问题,请参考以下文章