docker push 到docker hub 镜像库

将镜像推送到dockerhub 的过程就像将代码提交到git仓库一样

  • 注册dockerhub 账号

首先要有一个dockerhub 的账号,然后新建一个repo(仓库)

141019_3ZPf_2499632.png

比如,新建一个叫nginx的仓库,显示的结果就是nancydocker/nginx

  • 创建镜像

 可以从dockerhub上下载一个nginx的镜像来测试

如何查找镜像?使用docker search + imageName(镜像名),比如查找nginx 的镜像

docker search nginx

这样就会出来一大堆

[root@dscn1 ~]# docker search nginx
INDEX       NAME                                                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/nginx                                                  Official build of Nginx.                        7398      [OK]       
docker.io   docker.io/jwilder/nginx-proxy                                    Automated Nginx reverse proxy for docker c...   1179                 [OK]
docker.io   docker.io/richarvey/nginx-php-fpm                                Container running Nginx + PHP-FPM capable ...   478                  [OK]
docker.io   docker.io/jrcs/letsencrypt-nginx-proxy-companion                 LetsEncrypt container to use with nginx as...   255                  [OK]
docker.io   docker.io/kong                                                   Open-source Microservice & API Management ...   132       [OK]       
docker.io   docker.io/webdevops/php-nginx                                    Nginx with PHP-FPM                              91                   [OK]
docker.io   docker.io/kitematic/hello-world-nginx                            A light-weight nginx container that demons...   86                   
docker.io   docker.io/bitnami/nginx                                          Bitnami nginx Docker Image                      40                   [OK]
docker.io   docker.io/linuxserver/nginx                                      An Nginx container, brought to you by Linu...   27                   
docker.io   docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          19                   [OK]
docker.io   docker.io/tobi312/rpi-nginx                                      NGINX on Raspberry Pi / armhf                   13                   [OK]
docker.io   docker.io/wodby/drupal-nginx                                     Nginx for Drupal                                9                    [OK]
docker.io   docker.io/blacklabelops/nginx                                    Dockerized Nginx Reverse Proxy Server.          8                    [OK]
docker.io   docker.io/webdevops/nginx                                        Nginx container                                 8                    [OK]
docker.io   docker.io/nginxdemos/nginx-ingress                               NGINX Ingress Controller for Kubernetes         7                    
docker.io   docker.io/centos/nginx-18-centos7                                Platform for running nginx 1.10 or buildin...   5                    
docker.io   docker.io/1science/nginx                                         Nginx Docker images that include Consul Te...   4                    [OK]
docker.io   docker.io/nginxdemos/hello                                       NGINX webserver that serves a simple page ...   3                    [OK]
docker.io   docker.io/behance/docker-nginx                                   Provides base OS, patches and stable nginx...   2                    [OK]
docker.io   docker.io/pebbletech/nginx-proxy                                 nginx-proxy sets up a container running ng...   2                    [OK]
docker.io   docker.io/schmunk42/nginx                                        Legacy nginx image                              1                    
docker.io   docker.io/toccoag/openshift-nginx                                Nginx reverse proxy for Nice running on sa...   1                    [OK]
docker.io   docker.io/travix/nginx                                           NGinx reverse proxy                             1                    [OK]
docker.io   docker.io/goodguide/nginx-application-proxy                      No-configuration Nginx reverse proxy for a...   0                    [OK]
docker.io   docker.io/mailu/nginx                                            Mailu nginx frontend                            0                    [OK]
[root@dscn1 ~]# 

很明显第一个就是官方镜像,使用docker pull nginx 就可以拉取下来

[root@dscn1 ~]# docker images
REPOSITORY                                  TAG                 IMAGE ID            CREATED             SIZE
learn                                       latest              8e341a7f7afb        2 hours ago         139.5 MB
nancydocker/learn                           latest              8e341a7f7afb        2 hours ago         139.5 MB
docker.io/nginx                             latest              9e7424e5dbae        7 days ago          108.5 MB
nancydocker/nginx                           latest              9e7424e5dbae        7 days ago          108.5 MB
docker.io/dragonitenetwork/dragonite-java   latest              5df0d85fc3ca        4 weeks ago         247.5 MB
[root@dscn1 ~]# 

这是使用docker tag 改名之后的了

[root@dscn1 ~]# docker tag docker.io/nginx nancydocker/nginx
  • 登陆dockerhub 账号

本地的镜像都准备好之后,需要在本地登陆docker的账户

[root@dscn1 ~]# docker login -u 你的名字  -p 你的密码
[root@dscn1 ~]# docker login -u ****** -p ******
Login Succeeded
[root@dscn1 ~]# 

登陆成功之后就可以开始push

[root@dscn1 ~]# docker push nancydocker/nginx
The push refers to a repository [docker.io/nancydocker/nginx]
63c39cd4a775: Pushed 
350d50e58b6c: Pushed 
cec7521cdf36: Pushed 
Head https://registry-1.docker.io/v2/nancydocker/nginx/blobs/sha256:9e7424e5dbaeb9b28fea44d8c75b41ac6104989b49b2464b7cbbed16ceeccfc3: dial tcp: lookup registry-1.docker.io on 114.114.114.114:53: read udp 192.168.10.129:36712->114.114.114.114:53: i/o timeout
[root@dscn1 ~]# docker push nancydocker/nginx
The push refers to a repository [docker.io/nancydocker/nginx]
63c39cd4a775: Layer already exists 
350d50e58b6c: Layer already exists 
cec7521cdf36: Layer already exists 
latest: digest: sha256:a4fb15454c43237dbc6592c4f8e0b50160ceb03e852a10c9895cf2a6d16c7fe2 size: 948
[root@dscn1 ~]# 

第一遍push 的时候超时了,但前三个都已经push 成功了,所以第二次推送的时候就会提示 layer already exists

转载于:https://my.oschina.net/u/2499632/blog/1582091

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值