🌍 Docker Hub

πŸ“‹ Docker Image Formats and Registry Usage

FormatExampleMeaning
Official Imagedocker pull ubuntuPulls from Docker’s official repo
Username/Imagedocker pull ommapari/appPulls from a specific Docker Hub user
Private Registrydocker pull 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-appPulls from a private registry
With Tagdocker pull nginx:1.23.4Pulls a specific version
With Digestdocker pull nginx@sha256:xyzPulls a fixed image version
Why use digests? Guarantees that the pulled image never changes, unlike latest.

Note: Always login before pulling

πŸš€ Deploy Private Registry and Pull Images

Setting up a Private Registry

docker run -d --name=my-registry -p 5000:5000 --restart always registry:2

Pull and Tag Images

docker pull nginx:latest httpd:latest
 
docker image tag nginx localhost:5000/nginx:latest

View Tagged Images

docker images                  
REPOSITORY           TAG    IMAGE ID    CREATED     SIZE
localhost:5000/nginx      latest  53a18edff809  6 weeks ago   192MB
nginx              latest  53a18edff809  6 weeks ago   192MB

Push to Private Registry

docker image tag nginx localhost:5000/nginx:latest

Query Registry Catalog

curl -X GET localhost:5000/v2/_catalog
{"repositories":["httpd","nginx"]}

Pull from Private Registry

docker pull localhost:5000/nginx

πŸ–ΌοΈ Docker Hub Examples

Docker Hub Interface

Registry Management

πŸ’‘ Best Practices

  • Always use specific tags instead of latest in production
  • Use digests for guaranteed immutable deployments
  • Set up private registries for proprietary applications
  • Regularly scan images for security vulnerabilities
  • Keep images lightweight by using minimal base images
  • Use multi-stage builds to reduce final image size