Reputation: 856
I'm currently learning about gitlab-ci, and deploying. My gitlab instance runs in a docker container, and I would like to use the host's docker in order to build and deploy an image.
Is there such a way to do this?
Upvotes: 0
Views: 173
Reputation: 3739
Yes. If docker is not installed in the image (the current gitlab/gitlab-ce doesn't have it) you need to extend the image with an installation. E.g.
FROM gitlab/gitlab-ce:8.14.4-ce.0
ENV DOCKER_API_VERSION 1.23
RUN apt-get update && apt-get install -y docker.io
The ENV DOCKER_API_VERSION 1.23
is there to ensure API compatibility between the installations. At the time of writing, you'll receive version 1.12.1
from the apt-get install
. If you have the same version on the host, then you can leave out the environment variable. If you have 1.11
on the host, then you'll need it (if you have some other version, you'll get an error message with the version number to use).
Build the image like this
docker build -t myrepo/myorg/mygitlab:8.14.4-ce.0 .
And then run it like this
docker run -d --name gitlab -v /var/run/docker.sock:/var/run/docker.sock myrepo/myorg/mygitlab:8.14.4-ce.0
You'll now have docker available from the container:
docker exec -it gitlab bash
$~ docker ps
Upvotes: 1