8 获取和推送镜像以及配置本地源

版权声明:版权声明:本文为博主原创文章,未经博主允许不得转载。https://blog.csdn.net/kan2016 https://blog.csdn.net/kan2016/article/details/84932190

1.查找镜像   search

方法1:

Docker Hub 的官方网站   https://hub.docker.com/   

方法2:

docker search [OPTIONS]  TERM
eg:docker search ubuntu
#查找3星级以上的结果
eg:docker search -s 3 ubuntu

--automated-false     自动化选项,显示自动化构建出的docker镜像

--no-trunc=false       如果为true,不以截断的方式显示输出

-s,--starts=0             用来限定显示结果的最低星级

最多返回25个结果

2.拉取镜像     pull

#登录
docker login daocloud.io
Username:<DaoCloud 用户名>
Password:<DaoCloud 密码>

#pull
docker pull daocloud.io/<用户名>/<镜像名称>:<Tag> 
# 例如
docker pull daocloud.io/daocloud/dao-redis:master-init

-a,--all-tags=false    指定了-a,pull命令可以将匹配到名字的镜像仓库中所有的镜像全部下载到本地

使用本地源: 

要先获得一个本地镜像的连接,使用daocloud提供的服务实现   https://www.daocloud.io/

注册后找到加速器并点击

该脚本可以将 --registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。

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

3.推送镜像  push   (目前仅限付费用户使用)

如果要把本地镜像 push 到 DaoCloud 镜像仓库(您的私有仓库),需要执行如下的步骤。首先您需要为镜像打一个 tag,下面的命令列出所有的镜像,并执行打 tag 打动作。在打 tag 时,需要使用镜像的 Image ID。另外,请注意打 tag 时,需要指明您的 DaoCloud 用户 ID,这样才会把镜像 push 到您的仓库,否则默认是到 DaoCloud 仓库的根目录,push 时会发生权限错误。

docker images
docker tag 9f676bd305a4 daocloud.io/<用户名>/ubuntu:v1
docker push daocloud.io/<用户名>/ubuntu:v1

猜你喜欢

转载自blog.csdn.net/kan2016/article/details/84932190