Hands-on Lab

#Lab: Container Registry

Set up and use a container registry.

#🎯 Objectives

  • Run local registry
  • Push and pull images
  • Tag images properly

#Task 1: Local Registry

bash
docker run -d -p 5000:5000 --name registry registry:2

#Task 2: Push Image

bash
1# Tag for local registry
2docker tag nginx:latest localhost:5000/nginx:1.0
3
4# Push
5docker push localhost:5000/nginx:1.0
6
7# List
8curl http://localhost:5000/v2/_catalog

#Task 3: Best Practices

bash
1# Semantic versioning
2docker tag myapp:latest myregistry/myapp:1.2.3
3
4# Git SHA tagging
5docker tag myapp:latest myregistry/myapp:$(git rev-parse --short HEAD)
6
7# Multi-tag
8docker tag myapp:latest myregistry/myapp:1.2.3
9docker tag myapp:latest myregistry/myapp:1.2
10docker tag myapp:latest myregistry/myapp:1
11docker tag myapp:latest myregistry/myapp:latest

#✅ Success Criteria

  • Registry running
  • Image pushed
  • Proper versioning used