Go to navigation

Frequently Asked Questions

I use Docker to build a container image and receive the error ERROR: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?. How can I fix it?

For building container images, we recommend using buildah or directly the buildah image. If you still want to use Docker, define the variables DOCKER_DRIVER: overlay2 and DOCKER_TLS_CERTDIR: "" in your .gitlab-ci.yml file, as shown in the example configuration below:

build:
  image: docker:latest 1
  variables:
    IMAGE_TAG: my-image:latest  2
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""
  services:
    - docker:dind
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
    - docker build -t $CI_REGISTRY_IMAGE/$IMAGE_TAG build 3
    - docker push $CI_REGISTRY_IMAGE/$IMAGE_TAG 4
  1. Image docker:latest
  2. Image name
  3. Build the my-image:latest image from the build directory
  4. Command that pushes the image to the current project’s Container Registry.