Record the steps of uploading images to DockerHub, but after careful consideration, do ordinary people have this requirement? After all, the services of DockerHub are intermittent in China.
cause
The performance of the Tencent Cloud lightweight server is too junk. The Dockerfile you wrote yourself compiles the image remotely. The Tokyo 1-core 2G machine of the Tencent Cloud lightweight machine is directly disconnected. Many attempts to compile the image have failed, so you can only compile it locally, and then synchronize it to the remote machine through a method.
The Docker Hub is the official image hosting platform. Its usage is similar to that of the Git hosting platform, but its hosting content is not Git projects, but Docker images.
step
1. Registered account
First, you need to register an account on Docker's official website, visit the following Url and register as prompted:
https://hub.docker.com/signup
Note: A special network may be required to open the web page and load the verification code.
2. Create warehouse
Next, you need to create an image warehouse. If you have logged in, visit the link in step 1. The Create Warehouse button is displayed in the upper right corner of the page, as shown below:
Click Create, select the public/private attributes of the warehouse, and fill in the warehouse name.
3. Baler login
On the packer, enter the following command to log in to the DockerHub account:
docker login
After entering, press the prompt to enter the account password in turn.
4. Build Dockerfile and modify Tag
First, build the image according to the conventional method (take my psn api project as an example):
#Enter the directory of Dockerfile cd psn-api # build docker build -t psn-api .
Then modify the image tag to remote warehouse tag:
#Psn api is the local image name azimiao/psn api is the remote name docker tag psn-api azimiao/psn-api
5. Push Image
Next, similar to the Git operation method, use the following command to push the local image to the DockerHub:
docker push azimiao/psn-api
6. Verification
After the push is completed, the details of the push can be seen on the warehouse web page, as shown in the following figure:
Try to pull the Docker image on another machine and run it:
docker run -itd --name psn-api -p 4000:4000 azimiao/psn-api
If it works properly, it will work normally.