I have setup a gitlab runner in docker on my local machine. It all is working fine. When the pipeline starts, the runner seems to handle the workload
But, I would like to do this locally. For example, if you downloaded the gitlab-runner executable, you can run stages locally
$> gitlab-runner exec docker linting
But in my case I have the runner started in docker and I don't have the executable gitlab-runner
. So my question is, is there a docker equivalent for this?
gitlab-runner exec
works as its own standalone command and runs the job in the context of where the executable is called -- it will not cause the job to be run on a registered runner. It is solely a local operation, so you must have the binary available.
You can run gitlab-runner exec
inside of your runner container or a new container if you want.
For example (assuming Linux platform):
docker run --rm \
-v $(pwd):/workspace \ # mount directory to the container
--workdir /workspace \ # set working directory
-v /var/run/docker.sock:/var/run/docker.sock \ # enable docker
--privileged \
--entrypoint="gitlab-runner" \ # set entrypoint
gitlab/gitlab-runner:latest exec docker MY_JOB
Or use doker exec
to run the command on your existing container:
docker exec -it my-running-container-name gitlab-runner exec docker linting
Though, you will want to make sure the .gitlab-ci.yml
file and project files are present in the container when you start it...