🧪 Basic Pipeline
- Build Strategy Options: there are two main ways to build Docker images in GitLab CI:
- Option A: Docker-in-Docker (DinD)
- Requires privileged: true.
- Enables full Docker commands inside a container.
- More self-contained but slower and more complex.
- Option B: Test in default container and split Jobs
- login_job – performs Docker login.
- build_job – builds and tags the image.
- push_job – pushes to registry.
- Use cache: to persist login credentials between jobs.
1 2 3 4
cache: key: docker-login paths: - ~/.docker/config.json
- Use cache: to persist login credentials between jobs.
- Automatically triggered by:
- Pushes to main, feature/*, or merge requests.
- Scheduled nightly CI jobs.
- By default, these jobs are run in parallel
- Option A: Docker-in-Docker (DinD)
- Image Deployment
- After downloading:
1
docker load -i image.tar
- Final deployment pushes image to GitLab Container Registry or Docker Hub.
- After downloading: