Docker build

Docker build

Building container image uses services

Use docker:dind for containerized Docker daemon

The GitLab runner must be configured to run privileged container

Alternatives: Rootless and or daeamonless builds using…

Hands-On 1/

Package binary in container image

  1. Add Dockerfile to repository
  2. Create new stage called package after test
  3. Add job package in stage package

       image: docker:20.10.21
       stage: package
       - docker build --tag hello .

Hands-On 2/2

Package binary in container image

  1. Add service to job package

       - name: docker:20.10.21-dind
         command: [ "dockerd", "--host", "tcp://" ]

See new .gitlab-ci.yml:

git checkout origin/160_gitlab_ci/230_docker -- '*'