How To Create a Docker Image during GitLab Pipeline

k8s

Use:

  • image docker:dind
  • selector: tags: - kubernetes
  • docker daemon detached dockerd &

Example:

create_docker_image:
    image: docker:dind
    stage: build
    script:
        - dockerd &
        - sleep 5
        - docker build -t <registry>/docs:1.0.0 --no-cache .
    only:
        - master
    tags:
        - kubernetes