Skip to content
Advertisement

GitLab CI docker build – docker: not found – exit code 127

I’m trying to create a CI/CD Pipeline for a simple java/maven project. The runner that I’m using is a docker runner.
I’m using a dockerfile to create a container which installs maven/java/etc.. and in this container the program should be tested.

Sorry for the question but I am new to CI/CD Pipelines in GitLab.

GitHub works just fine have a look: https://github.com/ni920/CICD-Test

Thank you


Here are the CI logs

JavaScript

Thats the .gitlab-ci.yml

JavaScript

Thats the dockerfile

JavaScript

Advertisement

Answer

Running your pipelines using the Docker executor means that your jobs will run in a Docker container, but not that you will be able to execute docker commands.

If you need to run docker commands inside a GitLab CI job (read “inside a container”) you will need Docker-in-Docker (often abbreviated DinD). It is a vast topic on itself but you can get started with GitLab CI‘s documentation: Use Docker to build Docker images


I always use DinD and have a minimal setup in my gitlab-ci.yml.

Using a docker image as a default:

JavaScript

Define a default variable for TLS certificates:

JavaScript

Then use a docker image as a service to enable DinD:

JavaScript

I wrote a few posts about using Docker-in-Docker on GitLab CI that you may find useful, but I still recommend to extensively read GitLab‘s documentation before reading them.

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