Reputation: 5661
I am using docker for my dev environment: I have a dev image and I mount my source files as a volume.
But then I wanted to do the same on my continuous integration server (gitlab ci) and I carefully read docker doc's reference to https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ but the solution of bind-mounting docker's unix socket into a docker client container makes impossible mounting volumes from it.
So basically my question is how would you solve this (given I am in a docker ci server/runner): I need to run the following command from a container (a gitlab runner).
$ git clone ... my-sources && cd my-sources
$ docker run my-dev-image -v $PWD:$PWD -w $PWD gcc main.c
Because obviously, the volume is taken from docker's "native" host and not the current container.
Upvotes: 1
Views: 1123
Reputation: 1754
Way I've solved this is making sure that build paths are SAME on host and CI container. e.g - starting container with -v /home/jenkins:/home/jenkins
. This way we have volume mounted from host to CI container. You can change to whatever directory you like, just making sure that jenkins
user's home is set to that directory.
Note: I'm using jenkins as example, but any CI will work with same principle
Upvotes: 1
Reputation: 15501
Make sure that your CI server is started with a volume (e.g. docker run --name gitlabci -v /src gitlabci …
), then, when you start the other containers, start them with docker run --volumes-from gitlabci …
. That way, /src
will also be available in those containers, and whatever you put in this directory (from the CI server) will be available in the other containers.
Upvotes: 0