Skip to content
Advertisement

Couldn’t connect to Docker daemon

I am new in Docker and CICD I am using a vps with Ubuntu 18.04. The docker of the project runs locally and works fine. I don’t quite understand why the server is trying to find the docker on http, not on tcp.

  • override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd

docker service status

enter image description here

  • daemon.json
{ "storage-driver":"overlay" }
  • gitlab-ci.yml
image: docker/compose:latest
services:
  - docker:dind
stages:
  - deploy
variables:
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""

deploy:
  stage: deploy
  only:
    - master
  tags:
    - deployment
  script:
    # - export DOCKER_HOST="tcp://127.0.0.1:2375"
    - docker-compose stop || true
    - docker-compose up -d 
    - docker ps 

  environment:
    name: production
  • Error

enter image description here

Advertisement

Answer

Set the DOCKER_HOST variable. When using the docker:dind service, the default hostname for the daemon is the name of the service, docker.

variables:
    DOCKER_HOST: "tcp://docker:2375"

You must have also setup your GitLab runner to enable privileged containers.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement