The reason it works like this is the bind mount is done from host, so need
a valid fully qualified host path, but the `pwd` command is ran inside
jenkins container, so resolves to container filesystem.
A possible alternate approach is for you to rely on " --volumes-from
$(hostname) ", as a container hostname defaults to it's ID. As a result,
your second container will share /var/jenkins_home with jenkins master.
Then you can run some commands using $workspace as a valid path in both
containers :

docker run --rm --volumes-from $(hostname) graviteeio/python3 python
${WORKSPACE}/package_bundles.py

2016-05-18 10:34 GMT+02:00 Nicolas Geraud <nicolas.ger...@gmail.com>:

> Thanks for the quick answer, I'll test this tonight.
>
> Do you have any blog post (or perhaps i've missed a "Quoi de neuf Docker"
> episode) which explain why it works like this ?
>
> Le mercredi 18 mai 2016 10:28:05 UTC+2, nicolas de loof a écrit :
>>
>> For this to work, you'll need the host path to be the exact same as the
>> jenkins container path, i.e. not use /opt/jenkins but /var/jenkins_home
>> on host
>> so `pwd` will resolve to some /var/jenkins_home/... subfolder that make
>> sense to be mounted from host into your side container
>>
>> 2016-05-18 10:14 GMT+02:00 Nicolas Geraud <nicolas...@gmail.com>:
>>
>>> Hi all,
>>>
>>> i'm using a dockerized jenkins (from jenkinsci/jenkins:2.2) and mounting
>>> the following volumes from my host :
>>> volumes:
>>>         - "/opt/jenkins:/var/jenkins_home"
>>>         - "/var/run/docker.sock:/var/run/docker.sock"
>>>
>>>
>>> I've created a job that launch a docker container to build some python
>>> files :
>>> --Dockerfile
>>>
>>> FROM python:3-onbuild
>>> CMD [ "python" ]
>>>
>>>
>>> docker command of my jenkins job :
>>> $docker run --rm -v `pwd`:"/usr/src/myapp" graviteeio/python3 python
>>> src/main/python/package_bundles.py
>>>
>>> But the result is :
>>>
>>>
>>> Starting docker_package_bundle_and_publish_1
>>> Attaching to docker_package_bundle_and_publish_1
>>> [36mpackage_bundle_and_publish_1 | [0m python: can't open file './src/
>>> main/python/package_bundles.py': [Errno 2] No such file or directory
>>> [36mdocker_package_bundle_and_publish_1 exited with code 2
>>> [0mFinished: SUCCESS
>>>
>>>
>>> This is working fine on a classic jenkins, but not on a dockerized jenkins. 
>>> I've googled this error and it seems that mounting a volume inside a 
>>> container with an already mounting volume doesn't work.
>>>
>>> I think that some of you have already test the same use case so, how to do 
>>> that ?
>>>
>>> Thanks for any clue.
>>> I need to test a data volume instead of mounting a host volume.
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to jenkinsci-use...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/f847d41e-3b28-4b2b-b61e-ca0bf2927e5e%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/f847d41e-3b28-4b2b-b61e-ca0bf2927e5e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/f8487560-3e1a-44a2-883f-b5ae02213cc1%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/f8487560-3e1a-44a2-883f-b5ae02213cc1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CANMVJz%3DFuxvJNRxu2z1-KCiNguQ%2Bz0srqeds9Hwsnjbhf4pM-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to