4

I use the Jenkins Docker plugin to build my image (this works), I can run the container just fine with a command like

 docker run test-env:latest /etc/bootstrap.sh -jenkins

However, when I run

 docker run -u root -v $WORKSPACE:/test test-env:latest /etc/bootstrap.sh -jenkins

I run in to some issues. The volume /test exists in the container, however it contains none of the files that $WORKSPACE has. Before running my docker container I do a

cd $WORKSPACE && ls -al

which shows the following contents:

total 52
drwxr-xr-x 10 root root 4096 Sep  3 15:49 .
drwxr-xr-x  3 root root 4096 Sep  3 15:49 ..
drwxr-xr-x  8 root root 4096 Sep  3 15:49 .git
-rw-r--r--  1 root root  361 Sep  3 15:49 .gitignore
-rw-r--r--  1 root root   71 Sep  3 15:49 README.md
drwxr-xr-x  3 root root 4096 Sep  3 15:49 bin
-rw-r--r--  1 root root 1900 Sep  3 15:49 build.sbt
drwxr-xr-x  3 root root 4096 Sep  3 15:49 conf
drwxr-xr-x  2 root root 4096 Sep  3 15:49 docs
drwxr-xr-x  2 root root 4096 Sep  3 15:49 lib
drwxr-xr-x  2 root root 4096 Sep  3 15:49 project
drwxr-xr-x  3 root root 4096 Sep  3 15:49 scripts
drwxr-xr-x  4 root root 4096 Sep  3 15:49 src

and see the git repository (test_repo) I want to share with the container is there with all the correct files, but inside the container when I do

cd /test && ls -al

all I see is

total 16
drwxr-xr-x 4 root root 4096 Sep  2 14:30 .
drwxr-xr-x 1 root root 4096 Sep  3 10:27 ..
drwxr-xr-x 3 root root 4096 Sep  2 13:26 test_repo
drwxr-xr-x 5 root root 4096 Sep  2 14:30 target

both of which do not contain my code, which I verified with further testing by using $WORKSPACE/test_repo and $WORKSPACE/target as the volumes I mount.

Why are none of my $WORKSPACE files visible in the container? How can I get it to work properly?

Edit: value of $WORKSPACE = /var/tmp/workspace/test-jenkins where test-jenkins is the name of my Jenkins job

Gabe Cohen
  • 85
  • 7
  • what is the value of `$WORKSPACE`? could you edit your question with the output of the following command: `echo $WORKSPACE` – Thomasleveil Sep 04 '15 at 13:50
  • @Thomasleveil value of $WORKSPACE = /var/tmp/workspace/test-jenkins ....test-jenkins is the name of my Jenkins job, sharing -v /var/tmp/workspace/test-jenkins yields the same result as above – Gabe Cohen Sep 04 '15 at 14:11
  • what does `docker run --rm -v /var/tmp/workspace/test-jenkins:/test busybox ls -l /test` show? – Thomasleveil Sep 04 '15 at 14:57
  • @Thomasleveil `total 8 drwxr-xr-x 3 root root 4096 Sep 3 14:37 test_repo drwxr-xr-x 5 root root 4096 Sep 4 13:23 target` – Gabe Cohen Sep 04 '15 at 15:15
  • and `docker run --rm -v /var/tmp/workspace/test-jenkins:/test test-env:latest ls -l /test`? – Thomasleveil Sep 04 '15 at 15:23
  • @Thomasleveil same result `total 8 drwxr-xr-x 3 root root 4096 Sep 3 10:37 test_repo drwxr-xr-x 5 root root 4096 Sep 4 09:23 target` – Gabe Cohen Sep 04 '15 at 15:27
  • 1
    It seems the issue is not related to the docker volume. The issue might then be with `/etc/bootstrap.sh` or your Dockerfile. You would need to share them as well in your question – Thomasleveil Sep 04 '15 at 21:17

0 Answers0