docker仓库命令

一 注册登录
1、注册
在 https://hub.docker.com/ 官网注册一个用户,需要输入用户名,密码和邮箱。
2、登录
[root@localhost ~]# docker login -u cakin24 -p ******
Login Succeeded
[root@localhost ~]#
 
二 上传本地镜像到官方https://hub.docker.com
[root@localhost ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (cakin24): cakin24
Password: 
Login Succeeded
添加新的标签:cakin24/hello-world
[root@localhost ~]# docker tag 48b5124b2768 cakin24/hello-world
[root@localhost ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
test/while              latest              cf1473016855        25 hours ago        118.8 MB
docker.io/httpd         2.2                 3624a4b77da8        2 weeks ago         169.9 MB
docker.io/ubuntu        latest              0ef2e08ed3fa        2 weeks ago         130 MB
cakin24/hello-world     latest              48b5124b2768        9 weeks ago         1.84 kB
docker.io/hello-world   latest              48b5124b2768        9 weeks ago         1.84 kB
docker.io/ubuntu        15.10               9b9cb95443b5        8 months ago        137.2 MB
 
三 上传镜像cakin24/hello-world:latest
[root@localhost ~]# docker push cakin24/hello-world:latest
The push refers to a repository [docker.io/cakin24/hello-world]
98c944e98de8: Mounted from library/hello-world 
latest: digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 size: 524
 
四 查看镜像是否传送成功
在Docker Hub上也可以看到自己的推送的tag
1.png
 
五 阿里云镜像加速
1)注册个帐号
https://dev.aliyun.com/search.html
阿里云会自动为用户分配一个镜像加速器的地址,登录后进入"管理中心"-->"加速器",里面有分配给你的镜像加速器的地址以及各个环境的使用说明。
镜像加速器地址:https://XXXXXX.mirror.aliyuncs.com
2)针对Docker客户端版本大于1.10的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https:// XXXXXX .mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
3)下载镜像时正常pull即可,比如:docker pull centos,docker会使用阿里云镜像进行加速。
 
六 怎样将本地镜像推送到阿里云
参考:https://ninghao.net/video/3780
1、在Docker镜像仓库管理页中的Namespace管理中增加namespace,笔者新增namespace为cakin24
2、在镜像列表中心增一个仓库,笔者新增仓库为nodejs-demo
3、登录阿里云的docker ,登录信息可从镜像信息中获取
[root@localhost ~]# sudo docker login --username=chengqiuming24 registry.cn-qingdao.aliyuncs.com
Password: 
Login Succeeded
4、从阿里云( https://dev.aliyun.com/search.html )中随便获取一个nodejs-demo镜像
[root@localhost ~]# docker pull registry.cn-hangzhou.aliyuncs.com/qinyujia-test/nodejs-demo
Using default tag: latest
Trying to pull repository registry.cn-hangzhou.aliyuncs.com/qinyujia-test/nodejs-demo ... 
latest: Pulling from registry.cn-hangzhou.aliyuncs.com/qinyujia-test/nodejs-demo
fdd5d7827f33: Pull complete 
a3ed95caeb02: Pull complete 
0f35d0fe50cc: Pull complete 
b6c4c5059134: Pull complete 
84b4a3d2dd20: Pull complete 
1fffbcac12f9: Pull complete 
Digest: sha256:4fe48f4fc825e258455b4e874b854c95b72cea94577931f174a22e6c74b52d87
5、查看本地镜像
[root@localhost ~]# docker images
REPOSITORY                                                    TAG                 IMAGE ID            CREATED             SIZE
test/while                                                    latest              cf1473016855        3 days ago          118.8 MB
docker.io/centos                                              latest              98d35105a391        6 days ago          192.5 MB
docker.io/httpd                                               2.2                 3624a4b77da8        3 weeks ago         169.9 MB
docker.io/ubuntu                                              latest              0ef2e08ed3fa        3 weeks ago         130 MB
docker.io/hello-world                                         latest              48b5124b2768        9 weeks ago         1.84 kB
registry.cn-hangzhou.aliyuncs.com/qinyujia-test/nodejs-demo   latest              905bb442e985        3 months ago        231.6 MB
docker.io/ubuntu                                              15.10               9b9cb95443b5        8 months ago        137.2 MB
6、新增一个镜像,取名tag为v1
[root@localhost ~]# sudo docker tag 905bb442e985 registry.cn-qingdao.aliyuncs.com/cakin24/nodejs-demo:v1
[root@localhost ~]# docker images
REPOSITORY                                                    TAG                 IMAGE ID            CREATED             SIZE
test/while                                                    latest              cf1473016855        3 days ago          118.8 MB
docker.io/centos                                              latest              98d35105a391        6 days ago          192.5 MB
docker.io/httpd                                               2.2                 3624a4b77da8        3 weeks ago         169.9 MB
docker.io/ubuntu                                              latest              0ef2e08ed3fa        3 weeks ago         130 MB
docker.io/hello-world                                         latest              48b5124b2768        9 weeks ago         1.84 kB
registry.cn-hangzhou.aliyuncs.com/qinyujia-test/nodejs-demo   latest              905bb442e985        3 months ago        231.6 MB
registry.cn-qingdao.aliyuncs.com/cakin24/nodejs-demo          v1                  905bb442e985        3 months ago        231.6 MB
docker.io/ubuntu                                              15.10               9b9cb95443b5        8 months ago        137.2 MB
7、将本地镜像推送到阿里云仓库
[root@localhost ~]# docker push registry.cn-qingdao.aliyuncs.com/cakin24/nodejs-demo:v1
The push refers to a repository [registry.cn-qingdao.aliyuncs.com/cakin24/nodejs-demo]
9a761a5d9ce3: Pushed 
5f70bf18a086: Pushed 
66cb9cbd7dad: Pushed 
fa4fdea31e29: Pushed 
bd750002938c: Pushed 
917c0fc99b35: Pushed 
v1: digest: sha256:eb2ba5718951e5f48f49303683f3b92af1b488d925b64d8b9d3bce9119120569 size: 2197
8、验证推送是否成功。

 

 

猜你喜欢

转载自cakin24.iteye.com/blog/2372488
今日推荐