Pipeline is returning: Docker not found

I have self-hosted GitLab runner, hosted on ubuntu 22.04 virtualbox vm with config as:

And pipeline file that I want to execute as:

stages:
  - build
  - deploy

build_image:
  stage: build
  tags:
    - vlatkodocker3
  before_script:
    - docker info
  script:
    - pwd


When I tried to execute it, I got:

Running with gitlab-runner 16.3.0 (8ec04662)
  on vlatkodocker3 xDo3UinQ, system ID: s_fae85db10a2f
Preparing the "docker" executor 00:03
Using Docker executor with image alpine:3.15.1 ...
Pulling docker image alpine:3.15.1 ...
Using docker image sha256:e9adb5357e84d853cc3eb08cd4d3f9bd6cebdb8a67f0415cc884be7b0202416d for alpine:3.15.1 with digest alpine@sha256:d6d0a0eb4d40ef96f2310ead734848b9c819bb97c9d846385c4aca1767186cd4 ...
Preparing environment 00:01
Running on runner-xdo3uinq-project-48666118-concurrent-0 via ubuntu-2204...
Getting source from Git repository 00:02
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/drivein1/gitlab-ci-cd-from-zero-to-hero-by-nana/.git/
Checking out 98f5adeb as detached HEAD (ref is main)...
Skipping Git submodules setup
Executing "step_script" stage of the job script 00:01
Using docker image sha256:e9adb5357e84d853cc3eb08cd4d3f9bd6cebdb8a67f0415cc884be7b0202416d for alpine:3.15.1 with digest alpine@sha256:d6d0a0eb4d40ef96f2310ead734848b9c819bb97c9d846385c4aca1767186cd4 ...
$ docker info
/bin/sh: eval: line 128: docker: not found
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 127

-The Docker package is installed on the Ubuntu runner host.
-all the access privileges are granted.

Suggest rotating your runner token. It is leaked in the screenshot.

The docker package needs to be installed on the GitLab runner host, then executing docker info should work.

2 Likes

hey @dnsmichi
thanks for your message

seems like:
-docker package is installed properly on the Ubuntu host
-all the access privileges are granted.

Please check my updated post.

In the job log, it says it is using docker executor (cautious - you have two registrations in config.toml, one is shell and one docker executor! Iā€™m not sure, but normally it should be only one.)

This means, your job is running using docker executor, inside alpine:latest image - which does not see docker on the host, only what is inside alpine container.

In order to use docker in combo with docker executor, you need to use docker as job image, and docker:dind image as service - have a look at official docs.

Hope this helps :slight_smile:

1 Like