<p>In configuration settings of Docker plugin for Jenkins, there were missing mountings for the volumes, because I was deploying docker images within docker slave container, so that the "master" docker container (with Jenkins slave agent) couldn't access the real files from the host machine.</p>

CC BY-SA 4.0
2019-08-14T09:44:07.663Z
2019-08-14T09:44:07.663Z
Patryk
<p>I'm working on a CI Jenkins build with scripted pipeline. From Jenkins on one machine, I'm connecting with already configured Jenkins slave on another machine (M2). I'm able to successfully execute docker commands within the jenkins slave, however it seems that docker is unable to mount the volumes from the slave to the freshly started docker image.</p>

<pre><code>node('testImage') {
   ... //do some job including creation of volumes within the "testImage" container
    stage('Run WildFly instances') {
        //run wildfly relevant
        sh "docker run -d --restart=unless-stopped \
           -v /some/path/to/volume/in/jenkins/slave/container:/some/path/to/volume/within/wildfly14/container \
           -p 8380:8080 \
           -p 9380:9990 \
           -e JAVA_OPTS='-Xms256m -Xmx512m -Djava.net.preferIPv4Stack=true' \
           --name wildfly14 \
          ${DockerRegistryBase}${WildflyImageName}:${WildflyImageVersion}"
}
</code></pre>

<p>/some/path/to/volume exists within the jenkins slave docker image, because it's created within the lifecycle of the pipeline, but the wildfly14 container that I'm trying to run is unable to access /some/path/to/volume, because when I run </p>

<pre><code>docker exec -it wildfly14 ls -lR /some/path/to/volume/within/wildfly14/container
</code></pre>

<p>it's simply empty. Any suggestions on why is it even happening? I've noticed that the docker containers are set up outside of the jenkins slave container, on the actual machine (M2). Could it be the reason that docker tries to map a volume from outside of the container (/some/path/to/volume) on M2 instead of the location within the jenkins slave?</p>

CC BY-SA 4.0
2019-06-12T09:23:04.837Z
are there any docker related errors? What are the permissions of the volume path?
man0v
CC BY-SA 4.0
2019-06-14T07:37:59.270Z
I've made a mistake of not configuring the proper volume mountins inside docker plugin, now it's fixed
Patryk
CC BY-SA 4.0
2019-08-03T05:48:42.743Z
Could you please answer your own question so that this question will be marked as answered?
Bruce Becker
<docker><jenkins><jenkins-pipeline><jenkinsfile>
Docker fails to mount volume inside Jenkins scripted pipeline
Patryk
# Docker fails to mount volume inside Jenkins scripted pipeline

(Asked by: username_0 on 2019-06-12)

I'm working on a CI Jenkins build with scripted pipeline. From Jenkins on one machine, I'm connecting with already configured Jenkins slave on another machine (M2). I'm able to successfully execute docker commands within the jenkins slave, however it seems that docker is unable to mount the volumes from the slave to the freshly started docker image.
node('testImage') {
   ... //do some job including creation of volumes within the "testImage" container
    stage('Run WildFly instances') {
        //run wildfly relevant
        sh "docker run -d --restart=unless-stopped \
           -v /some/path/to/volume/in/jenkins/slave/container:/some/path/to/volume/within/wildfly14/container \
           -p 8380:8080 \
           -p 9380:9990 \
           -e JAVA_OPTS='-Xms256m -Xmx512m -Djava.net.preferIPv4Stack=true' \
           --name wildfly14 \
          ${DockerRegistryBase}${WildflyImageName}:${WildflyImageVersion}"
}

/some/path/to/volume exists within the jenkins slave docker image, because it's created within the lifecycle of the pipeline, but the wildfly14 container that I'm trying to run is unable to access /some/path/to/volume, because when I run 
docker exec -it wildfly14 ls -lR /some/path/to/volume/within/wildfly14/container

it's simply empty. Any suggestions on why is it even happening? I've noticed that the docker containers are set up outside of the jenkins slave container, on the actual machine (M2). Could it be the reason that docker tries to map a volume from outside of the container (/some/path/to/volume) on M2 instead of the location within the jenkins slave?

**Tags:** docker, jenkins, jenkins-pipeline, jenkinsfile

> **Comments:**
> **username_1**: are there any docker related errors? What are the permissions of the volume path?  
> **username_0**: I've made a mistake of not configuring the proper volume mountins inside docker plugin, now it's fixed  
> **username_2**: Could you please answer your own question so that this question will be marked as answered?  

---

## 1 answers

### Answer by username_0 on 2019-08-14. Score: 2

In configuration settings of Docker plugin for Jenkins, there were missing mountings for the volumes, because I was deploying docker images within docker slave container, so that the "master" docker container (with Jenkins slave agent) couldn't access the real files from the host machine.


---

