Pulling And Running Docker Images From Docker Hub
Download an image from Docker Hub and run it on another machine.
Once an image is pushed to Docker Hub, any machine with Docker can pull and run it.
This is the real power of Docker: build once, share the image, and run the same packaged application somewhere else.
Pull an image
Use:
docker pull username/maven-web-app:1.0Docker downloads the image layers and stores them locally.
Check:
docker imagesRun the pulled image
Start a container:
docker run -d -p 8080:8080 --name pulled-app username/maven-web-app:1.0Open:
http://localhost:8080If you are running this on AWS EC2, open:
http://ec2-public-ip:8080Make sure the EC2 security group allows port 8080.
Pull is automatic with docker run
If the image is not present locally, this command can pull it automatically:
docker run username/maven-web-app:1.0Still, using docker pull first is useful while learning because it makes the steps clear.
Useful checks
Use:
docker ps
docker logs pulled-app
docker stop pulled-app
docker rm pulled-appThese commands help confirm the container is running and clean it up when done.
Docker Hub is the handoff point. One machine pushes the image; another machine pulls and runs the exact same package.
Written By: Shiva Srivastava
How is this guide?
Last updated on
