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 kaniko , podman/buildah , BuildKit
Package binary in container image
Dockerfile
to repositorypackage
after test
Add job package
in stage package
package:
image: docker:20.10.18
stage: package
script:
- docker build --tag hello .
Add service to job package
package:
services:
- name: docker:20.10.18-dind
command: [ "dockerd", "--host", "tcp://0.0.0.0:2375" ]
#...
(See new .gitlab-ci.yml
)