Tag image The symbol that associates a local image with a repository on the registry is username/repository:tag. This tag is optional, but recommended, as it is the mechanism by which the Registrar provides versions for Docker images. Give the repository a meaningful name for the context, such as GET-started :part2. This will put the image into the GET-started repository and mark it as part2. Now, put them together to mark the mirror image. Run docker Tag Image with your username, repository, and tag name so that the image will be uploaded to the destination you want. The syntax for this command is:

docker tag image username/repository:tag
Copy the code

Such as:

docker tag friendlyhello john/get-started:part2
Copy the code

Run the Docker image to see the image of the new tag. (You can also use Docker Image ls.)

docker images
Copy the code
REPOSITORY TAG IMAGE ID CREATED SIZE 
 friendlyhello latest d9e555c53008 3 minutes ago 195MB 
 john/get-started part2 d9e555c53008 3 minutes ago 195MB 
 python 2.7-slim 1c7128a655f6 5 days ago 183MB 
Copy the code

Publish the image Upload your tag image to the repository:

docker push username/repository:tag
Copy the code

8. Download the image

Once completed, the result of this upload is public. If you log in to the Docker Hub, you’ll see the new image and its pull command. From now on, you can use the docker run command to use and run your application on any machine:

docker run -p 4000:80 username/repository:tag
Copy the code

If the image is not available locally on the machine, Docker will fetch it from the repository.