skip to Main Content

I have a linux vm on which I installed docker. I have several docker containers with the different programs I have to use. Here’s my architecture:

enter image description here

Everything is working fine except for the red box.

What I am trying to do is to dynamically provide a jenkins docker-in-docker agent with the cloud functionality in order to build my docker images and push them to the docker registry I set up.

enter image description here

I have been looking for documentation to create a docker in docker container and I found this:
https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

This article states that in order to avoid problems with my main docker installation I have to create a volume:

-v /var/run/docker.sock:/var/run/docker.sock

I tested my image locally and I have no problem to run

docker run -d -v --name test /var/run/docker.sock:/var/run/docker.sock

docker exec -it test /bin/bash

docker run hello-world

The container is using the linux vm docker installation to build and run the docker images so everything is fine.

However, I face problems when it comes to the jenkins docker cloud configuration.

From what I gather, since the #826 build, the docker jenkins plugin has change its syntax for volumes.

This is the configuration I tried:

enter image description here

And the error message I have when trying to launch the agent:

Reason: Template provisioning failed.
com.github.dockerjava.api.exception.BadRequestException: {"message":"create 
/var/run/docker.sock: "/var/run/docker.sock" includes invalid characters for a local 
volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a 
host directory, use absolute path"} 

I also tried that configuration:

enter image description here

Reason: Template provisioning failed.
com.github.dockerjava.api.exception.BadRequestException: {"message":"invalid mount config for type "volume": invalid mount path: './var/run/docker.sock' mount path must be absolute"}

I do not get what that means as on my linux vm the docker.sock absolute path is /var/run/docker.sock, and it is the same path inside the docker in docker I ran locally…

I tried to check the source code to find what I did wrong but it’s unclear what the code is doing for me (https://github.com/jenkinsci/docker-plugin/blob/master/src/main/java/com/nirima/jenkins/plugins/docker/DockerTemplateBase.java, from row 884 onward), I also tried with backslashes, etc. Nothing worked.

Has anyone any idea what is the expected syntax in that configuration panel for setting up a simple volume?

2

Answers


  1. Change the configuration to this:

    type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock

    it is not a volume, it is a bind type.

    Login or Signup to reply.
  2. This worked for me
    type=bind,source=/sys/fs/cgroup,target=/sys/fs/cgroup,readonly

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search