Building and running a docker container in a GoCD elastic agent?

8/20/2018

I have GoCD deployed in my Kubernetes cluster with the standard Helm chart, which configures it to use the Kubernetes elastic agent plugin and provides an example elastic profile which uses the gocd-agent-docker-dind docker image to provide docker-in-docker functionality.

What I'd like to do is to have my first stage build the Dockerfile in the repo, then have another stage execute the unit tests in the previously built docker image and parse the JUnit XML test result output. I managed to get the build and test execution working, but I'm having trouble extracting the test result files afterward.

I'm running a shell command like the following inside the elastic agent's image:

docker run -v "/test-results:/test-results" \
    test-image:v${GO_PIPELINE_LABEL} \
    --junit-xml /test-results/results.xml

But the directory is empty after the run, suggesting an issue with mounting a volume in a docker-in-docker situation.

Has anyone tried to accomplish anything like this before, or do you have any ideas how to resolve this?

-- user108471
docker
go-cd
kubernetes

0 Answers