Docker Build, Tag, Push Commands
Quick reference for building, tagging, and pushing Docker images to EBRAINS Docker Registry.
Build Image
Basic Build
Build with Context
Example Build Output
Tag Image
Tag Format for EBRAINS Registry
Single Tag
Multiple Tags (Semantic Versioning Strategy)
Environment-Based Tags
List Image Tags
Push Image
Push Single Tag
Push Multiple Tags
Push with Script
Complete Workflow Examples
Development Build and Push
Production Release
Multi-Architecture Build
Tagging Strategy Recommendations
| Tag Type | Format | Purpose | Example | Use Case |
|---|---|---|---|---|
| Semantic Version | MAJOR.MINOR.PATCH | Pin exact version | 2.1.3 | Production (no auto-updates) |
| Major.Minor | MAJOR.MINOR | Auto-update patches | 2.1 | Staging (get bug fixes) |
| Major | MAJOR | Auto-update minor | 2 | Development (brave) |
| latest | latest | Latest stable | latest | Development/Testing |
| Environment | env | Environment-specific | prod, staging, dev | Deployment targets |
| Git SHA | commit-sha | Exact build | abc123f | Debugging/Rollback |
| Pre-release | VERSION-label | Testing versions | 2.0.0-beta.1 | Beta testing |
Build Arguments
Define Build Args in Dockerfile
Pass Build Args
Image Management
List Images
Remove Images
Inspect Image
Troubleshooting
Build Fails - No Space Left
Tag Already Exists Remotely
Push Denied
Image Too Large
Best Practices
Do
- Use specific base image versions (e.g.,
python:3.11-slim, notpython:latest) - Tag with semantic versions for releases
- Use multi-stage builds to reduce image size
- Create
.dockerignoreto exclude unnecessary files - Tag with Git commit SHA for traceability
- Use layer caching effectively (copy dependencies first)
Don’t
- Don’t use
latesttag in production - Don’t include secrets in images (use environment variables)
- Don’t run as root user in containers
- Don’t store data in containers (use volumes)
- Don’t ignore build warnings
- Don’t skip security scanning
Related Documentation
- Docker Registry Reference - EBRAINS Harbor registry
- Publish Docker Image Tutorial - Complete guide
- Git Tagging Reference - Version tagging
- Docker Documentation - Official docs
- Dockerfile Best Practices - Docker guide