Cheat SheetsDockerCI/CD

CI/CD — Cheat Sheet

Docker · 1 topics. Download the PDF or the Instagram carousel and share it.

Cheat Sheet · AiCanCode.org
CI/CD
Docker1 topicsQuick revision reference
1

Docker Registry & Image Management

A registry stores and distributes Docker images. Understanding image tagging strategies, pushing to Docker Hub or cloud registries (ECR, GCR, ACR), and image scanning is essential for CI/CD pipelines.

  • Tags are mutable pointers; digests (SHA256) are immutable — use digests for reproducible prod deployments.
  • latest is just a tag convention, not a special feature — it is not automatically updated.
  • Use Git SHA tags in CI/CD for full traceability from running container back to source commit.
  • Scan images for CVEs (Trivy, Docker Scout) in CI before pushing to production registries.
  • Multi-arch builds (--platform linux/amd64,linux/arm64) support both Intel servers and Apple Silicon dev machines.
  • ECR, GCR, ACR are cloud-native private registries — prefer over Docker Hub for production.
bash — tagging and pushing to registries
# Build and tag

docker build -t myapp:latest .

docker build -t myapp:v1.2.3 .

docker build -t myapp:$(git rev-parse --short HEAD) .   # Git SHA tag



# Tag an existing image with a new name/registry

docker tag myapp:latest docker.io/myusername/myapp:latest

docker tag myapp:latest 123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:v1.2.3



# Push to Docker Hub

docker login                                              # auth

docker push myusername/myapp:latest



# Push to AWS ECR

aws ecr get-login-password --region us-east-1 | \

  docker login --username AWS --password-stdin \

  123456789.dkr.ecr.us-east-1.amazonaws.com



docker push 123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:v1.2.3



# Pull from private registry

docker pull 123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:v1.2.3
Learn this free with Aria, your AI tutor → AiCanCode.org/learn/docker