[JIRA] (JENKINS-57655) Can volumes-from be disabled for docker.image().inside() in a Jenkins pipeline?

6 views
Skip to first unread message

pieter@pietervogelaar.nl (JIRA)

unread,
May 24, 2019, 4:05:03 AM5/24/19
to jenkinsc...@googlegroups.com
Pieter Vogelaar created an issue
 
Jenkins / Improvement JENKINS-57655
Can volumes-from be disabled for docker.image().inside() in a Jenkins pipeline?
Issue Type: Improvement Improvement
Assignee: Unassigned
Components: docker-workflow-plugin
Created: 2019-05-24 08:04
Priority: Minor Minor
Reporter: Pieter Vogelaar

The Jenkins docker pipeline provides a very nice docker.image().inside() function. This will result in a docker run command like:

docker run -t -d -u 1000:1000 -w /var/jenkins_home/workspace/my-job --volumes-from 30dfde62097dad7873b0c72da82f70252jefewfr72edb412c2e759303d10 -e ******** -e ******** -e ******** my-image:latest cat

The `--volumes-from` parameter will provide the container with the same volumes as the main Jenkins container. So it will also expose the entire /var/jenkins_home directory.
Sometimes I would like to execute commands in a container and only expose the current job workspace.

Is it possible to disable/remove the `--volumes-from` parameter?

I can add an extra `v ${WORKSPACE}:/workspace` myself as args, but I can't find a way to disable/remove the `-volumes-from` parameter.

 

I also posted this on: https://stackoverflow.com/questions/56277847/can-volumes-from-be-disabled-for-docker-image-inside-in-a-jenkins-pipeline

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

pieter@pietervogelaar.nl (JIRA)

unread,
May 24, 2019, 4:05:05 AM5/24/19
to jenkinsc...@googlegroups.com
Pieter Vogelaar updated an issue
Change By: Pieter Vogelaar
The Jenkins docker pipeline provides a very nice docker.image().inside() function. This will result in a docker run command like:
{code:java}

docker run -t -d -u 1000:1000 -w /var/jenkins_home/workspace/my-job --volumes-from 30dfde62097dad7873b0c72da82f70252jefewfr72edb412c2e759303d10 -e ******** -e ******** -e ******** my-image:latest cat
{code}

The `--volumes-from` parameter will provide the container with the same volumes as the main Jenkins container. So it will also expose the entire /var/jenkins_home directory.
Sometimes I would like to execute commands in a container and only expose the current job workspace.

Is it possible to disable/remove the `--volumes-from` parameter?

I can add an extra ` - v ${WORKSPACE}:/workspace` myself as args, but I can't find a way to disable/remove the `- - volumes-from` parameter.

pieter@pietervogelaar.nl (JIRA)

unread,
May 24, 2019, 4:09:02 AM5/24/19
to jenkinsc...@googlegroups.com

pjo901018@gmail.com (JIRA)

unread,
Jul 10, 2019, 3:36:02 AM7/10/19
to jenkinsc...@googlegroups.com
Jaeyoung Park commented on Improvement JENKINS-57655
 
Re: Can volumes-from be disabled for docker.image().inside() in a Jenkins pipeline?

+1 

This feature adding --volumes-from flag is only mentioned on here. https://jenkins.io/doc/book/pipeline/docker/#using-a-remote-docker-server

When Jenkins detects that the agent is itself running inside a Docker container, it will automatically pass the --volumes-from argument to the inside container, ensuring that it can share a workspace with the agent.
Additionally some versions of Docker Swarm do not support custom Registries.

 
I hate "automatically" features. It's hard to find why did it happen. And hard to resolve it.
In my case, I want to isolate "docker in docker" environment, but "--volumes-from jenkins" gives a mounted "/var/run/docker.sock".

 

Reply all
Reply to author
Forward
0 new messages