skip to Main Content

Operation system CentOS Linux release 8.3.2011 x86_64

I try build image when push to master, this is my simple ci/cd config file .gitlab-ci.yml

image:
  name: docker/compose:alpine-1.29.2
  entrypoint: [""]

stages:
  - build

build-job:
  stage: build
  script:
    - echo $(whoami)
    - docker -v
    - docker-compose --version
    - docker-compose build --no-cache
    - docker-compose push
    - echo "Compile complete."
  only:
    - master

While pipeline running, i have next error

$ echo $(whoami)
root
$ docker -v
Docker version 19.03.15, build 99e3ed8
$ docker-compose --version
docker-compose version 1.29.2, build 5becea4
$ docker-compose build --no-cache
[21] Failed to execute script docker-compose
Traceback (most recent call last):
  File "urllib3/connectionpool.py", line 677, in urlopen
  File "urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1277, in request
  File "http/client.py", line 1323, in _send_request
  File "http/client.py", line 1272, in endheaders
  File "http/client.py", line 1032, in _send_output
  File "http/client.py", line 972, in send
  File "docker/transport/unixconn.py", line 43, in connect
...
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 200, in perform_command
  File "compose/cli/command.py", line 70, in project_from_options
  File "compose/cli/command.py", line 153, in get_project
  File "compose/cli/docker_client.py", line 43, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "docker/api/client.py", line 197, in __init__
  File "docker/api/client.py", line 222, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

I checked permission on sock files

ls -la /var/run/docker.sock
srw-rw-rw- 1 root docker 0 Feb  1 10:05 /var/run/docker.sock
ls -la /run/containerd/containerd.sock
srw-rw-rw- 1 root root 0 Feb  1 10:05 /run/containerd/containerd.sock

Docker service is running on host machine

systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-02-01 10:05:10 MSK; 27min ago
     Docs: https://docs.docker.com
 Main PID: 10698 (dockerd)
    Tasks: 10
   Memory: 430.4M
   CGroup: /system.slice/docker.service
           └─10698 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
...

Have anybody ideas?

2

Answers


  1. Chosen as BEST ANSWER

    Need transfer socket from host machine for each gitlab runner in /etc/gitlab-runner/config.toml (default path)

    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    

  2. I had a same issue .Here is a solution

    sudo service docker start
    

    or you can list images

    docker images
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search