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:
- docker login
Enter username and password to log in:
- docker@default:~$ 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: boonyadocker
- Password:
- Login Succeeded
- docker@default:~$
tag to modify the image name
The specification for pushing images is:
- docker push registered username/image name
The tag command is modified to the canonical image:
- docker tag boonya/tomcat-allow-remote boonyadocker/tomcat-allow-remote
Check out the modified spec mirror:
- docker@default:~$ docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- boonyadocker/tomcat-allow-remote latest 6137f64875dd 7 hours ago 571MB
- boonyadocker/tomcat-web latest 09677d05b579 2 days ago 571MB
- <none> <none> e1471ab1845a 3 days ago 188MB
- <none> <none> cf240e31edfb 3 days ago 188MB
- <none> <none> 717961796ae2 3 days ago 334MB
- apptomcat 1.0 249dc3f5dfb0 3 days ago 334MB
- tomcat 8 a2fbbcebd67e 8 days ago 334MB
- ubuntu 14.04 4a2820e686c4 2 weeks ago 188MB
- wurstmeister/kafka latest 12453f4efa7b 6 weeks ago 265MB
- docker@default:~$
推送镜像到Docker Hub
通过push命令推送镜像:
- docker push boonyadocker/tomcat-allow-remote:latest
注:推送Docker Hub速度很慢,耐心等待,很有可能失败,失败会尝试多次重传,之后断开推送(但已推送上去的会保留,保留时间不知道是多久)。
下面是上传完毕的输出(多次重传):
- docker@default:~$ docker push boonyadocker/tomcat-allow-remote:latest
- The push refers to a repository [docker.io/boonyadocker/tomcat-allow-remote]
- 464a44ea0195: Layer already exists
- 29b57e33a4da: Pushed
- d649a240e453: Layer already exists
- d0757a6730d0: Layer already exists
- 768dcfe5d05f: Layer already exists
- f5cfc06b640d: Layer already exists
- 9669d6b73383: Layer already exists
- latest: digest: sha256:1e7562a15ef1728f213922d9633be67f3025447d0a641e333a8ec5107749c386 size: 11802
- 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:
- docker@default:~$ docker search boonyadocker/tomcat-allow-remote
- NAME DESCRIPTION STARS OFFICIAL AUTOMATED
- boonyadocker/tomcat-allow-remote In this Tomcat image server you can use ma... 0
- 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:
- 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.