Push Your Image to Docker Hub
Pushing an image means three steps: log in, tag the image with your Hub name, and push it. Anyone with the name can then pull it on another machine.
Log in
This command signs in to Docker Hub.
docker loginTag with your name
The tag starts with your Hub name.
docker tag greet:1.0 your-name/greet:1.0Push it
This command uploads the image to Hub.
docker push your-name/greet:1.0Example
docker run -d --name g6-reg -p 8115:5000 registry:2 >/dev/null
sleep 2
docker tag g4-greet:1.0 localhost:8115/greet:1.0
docker push localhost:8115/greet:1.0
docker rmi localhost:8115/greet:1.0
docker pull localhost:8115/greet:1.0Key points
- Use docker login to sign in to Docker Hub from the terminal.
- Tag the image as your-name/image:version, with your Hub name first.
- Use docker push to upload the tagged image to Hub.
- Use docker pull on another machine to fetch it back.
- A public image is visible to everyone. A private image needs your login.
In this example, a local registry stands in for Docker Hub. The image is tagged with the registry address, pushed, removed, and pulled back. The pull proves the push stored the image, and Hub takes the same three commands with your name.
Note
This course verifies the push against a local registry, because no Hub account is used here. Hub takes the same three commands.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What are the three steps to push an image to Docker Hub?