I'm running a build in Jenkins which is running inside Kubernetes.

When the job starts, a container starts in the cluster and the build runs inside it.

A step in the build requires building an RPM using rpmbuild and for that matter I use this docker image.

So what happens is that when the job starts, it fires up a jenkins slave jnlp dind container with a volume mount of /var/run/docker.sock:/var/run/docker.sock, it then pulls the code from git and running a Makefile to build the code.

When the build process finishes, I want to fire up another container (the one containing rpmbuild), so from within the jnlp dind container I run:

docker run -e WORKSPACE=/home/jenkins/agent/workspace/product-Provisioner-3.17 -e PROV_NAME=product-provisioner -v ${WORKSPACE}:/srv --privileged -t registry/rpmbuild:latest /usr/bin/rpmbuild -v -bb --clean --define '_workspace /srv' /srv/provisioner/SPECS/${PROV_NAME}.spec

But for some reason the volume is not mounted and when I do kubectl exec -it jnlp-container sh, I see that the /srv directory doesn't contain the files in the ${WORKSPACE}.

Running the rpmbuild container just with --help works so the docker inside docker inside docker works, just the volume isn't mounted properly.

As far as I know, running a container from within another container should be doable.

What could be the reason that /srv is not mounted properly?

  • Why not just install rpmbuild in the first container? – Joao Vitorino Jan 20 at 19:49
  • Because it’s alpine linux – Itai Ganot Jan 20 at 22:10
  • Does WORKSPACE exist on the docker host, or just in the first container? – Preston Martin Mar 11 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.