Docker image push (push) to Docker Hub

Reprinted in: https://blog.csdn.net/boonya/article/details/74906927

After the image is successfully built, it can be used as long as there is a docker environment, but the image must be pushed to Docker Hub. The image we created before does not meet the tag requirements of Docker Hub, because the user name registered in Docker Hub is boonyadocker instead of boonya, so we need to modify the docker tag, and finally use the docker push command to push the image to the public warehouse.

Docker hub registered user

Go to the official website to register an account: https://hub.docker.com/

Log in to docker on local Linux:

[plain]  view plain  copy
  1. docker login  

Enter username and password to log in:

[plain]  view plain  copy
  1. docker@default:~$ docker login  
  2. 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.  
  3. Username: boonyadocker  
  4. Password:   
  5. Login Succeeded  
  6. docker@default:~$   

tag to modify the image name

The specification for pushing images is:

[plain]  view plain  copy
  1. docker push registered username/image name  

The tag command is modified to the canonical image:

[plain]  view plain  copy
  1. docker tag boonya/tomcat-allow-remote boonyadocker/tomcat-allow-remote  

Check out the modified spec mirror:

[plain]  view plain  copy
  1. docker@default:~$ docker images  
  2. REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE  
  3. boonyadocker/tomcat-allow-remote   latest              6137f64875dd        7 hours ago         571MB  
  4. boonyadocker/tomcat-web            latest              09677d05b579        2 days ago          571MB  
  5. <none>                             <none>              e1471ab1845a        3 days ago          188MB  
  6. <none>                             <none>              cf240e31edfb        3 days ago          188MB  
  7. <none>                             <none>              717961796ae2        3 days ago          334MB  
  8. apptomcat                          1.0                 249dc3f5dfb0        3 days ago          334MB  
  9. tomcat                             8                   a2fbbcebd67e        8 days ago          334MB  
  10. ubuntu                             14.04               4a2820e686c4        2 weeks ago         188MB  
  11. wurstmeister/kafka                 latest              12453f4efa7b        6 weeks ago         265MB  
  12. docker@default:~$   

推送镜像到Docker Hub

通过push命令推送镜像:

[plain]  view plain  copy
  1. docker push boonyadocker/tomcat-allow-remote:latest  

注:推送Docker Hub速度很慢,耐心等待,很有可能失败,失败会尝试多次重传,之后断开推送(但已推送上去的会保留,保留时间不知道是多久)。

下面是上传完毕的输出(多次重传):

[plain]  view plain  copy
  1. docker@default:~$ docker push boonyadocker/tomcat-allow-remote:latest  
  2. The push refers to a repository [docker.io/boonyadocker/tomcat-allow-remote]  
  3. 464a44ea0195: Layer already exists   
  4. 29b57e33a4da: Pushed   
  5. d649a240e453: Layer already exists   
  6. d0757a6730d0: Layer already exists   
  7. 768dcfe5d05f: Layer already exists   
  8. f5cfc06b640d: Layer already exists   
  9. 9669d6b73383: Layer already exists   
  10. latest: digest: sha256:1e7562a15ef1728f213922d9633be67f3025447d0a641e333a8ec5107749c386 size: 11802  
  11. docker@default:~$   

Still need patience, because large files are time-consuming.

Visit Docker Hub to publish images

After uploading, visit: https://hub.docker.com/r/boonyadocker/tomcat-allow-remote/ , as shown in the figure below, everyone can use the image I released:


Searching on Docker Hub can also be found:


At this point we have reached publishing our image to the Docker Hub repository.

Docker uses published images

Search for published mirrors:

[plain]  view plain  copy
  1. docker@default:~$ docker search boonyadocker/tomcat-allow-remote  
  2. NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED  
  3. boonyadocker/tomcat-allow-remote   In this Tomcat image server you can use ma...   0                      
  4. docker@default:~$  

Because we have already released our own image, we can directly use the docker pull command to pull and use the image in the future:

[plain]  view plain  copy
  1. docker pull boonyadocker/tomcat-allow-remote  


Note: The image is based on Tomcat8's remote management role permissions. The management account and password are: tomcat/password.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324747828&siteId=291194637