docker集装箱与jenkins安装量有困难

我使用Jenkins Docker插件来构build我的图像(这个工作),我可以使用类似的命令来运行容器

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

但是,当我跑步

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

我遇到了一些问题。 卷/testing存在于容器中,但它不包含$ WORKSPACE所具有的任何文件。 在运行我的docker集装箱之前,我做了一个

 cd $WORKSPACE && ls -al 

其中显示以下内容:

 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 

并看到我想与容器共享的git存储库(test_repo)是有所有正确的文件,但在我的容器内

 cd /test && ls -al 

我看到的只是

 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 

两者都不包含我的代码,我通过使用$ WORKSPACE / test_repo和$ WORKSPACE / target进行进一步testing来validation该代码。

为什么我的$ WORKSPACE文件在容器中不可见? 我怎样才能使它正常工作?

编辑:$ WORKSPACE的值= / var / tmp / workspace / test-jenkins其中test-jenkins是我Jenkins作业的名字