最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

linux - Jenkins docker plugin is mounting the workspace to the container - Stack Overflow

programmeradmin1浏览0评论

When running a container in my Jenkins CI like this:

image.inside('-v /build:/build:rw') {
    body()
}

the default Jenkins workspace, which in my case is /home/jenkins/workspace/kevin is being mounted to the docker container and any changes made in the container to that directory is being reflected on the host machine. I checked the docker command and I noticed that jenkins is mounting the default workspace inside the container like: -v /home/jenkins/workspace/kevin:/home/jenkins/workspace/kevin:rw,z

Why? How can I disable mounting the workspace to the container?

When running a container in my Jenkins CI like this:

image.inside('-v /build:/build:rw') {
    body()
}

the default Jenkins workspace, which in my case is /home/jenkins/workspace/kevin is being mounted to the docker container and any changes made in the container to that directory is being reflected on the host machine. I checked the docker command and I noticed that jenkins is mounting the default workspace inside the container like: -v /home/jenkins/workspace/kevin:/home/jenkins/workspace/kevin:rw,z

Why? How can I disable mounting the workspace to the container?

Share Improve this question asked Mar 20 at 9:40 Kevin NammourKevin Nammour 312 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Why?

The mundane answer is because it was invented that way.

Source code: https://github/jenkinsci/docker-workflow-plugin/blob/d3d06101cbc6e96e6d47c4c67517239e05dfafa5/src/main/java//jenkinsci/plugins/docker/workflow/WithContainerStep.java#L19 .

How can I disable mounting the workspace to the container?

sh "docker run ${image.imageName()} stuff"

You should also be able to overwrite the mount, like:

image.inside("-v /tmp:${WORKSPACE} -w / -u root:root")
发布评论

评论列表(0)

  1. 暂无评论