Alvaro: 

I posted this question here because of the Packer way to build Docker 
images, i.e. without using Dockerfiles. I'm hoping that this place has 
higher concentration of people who work with Docker without Dockerfiles and 
as such can help me with my query.
In case you are wondering, earlier snippet can be replicated using 
following Packer template 
<https://gist.github.com/IvanRibakov/fa69cc2fe87d133ff55405d384638f66>. 
P.S. last line in the snippet should be "docker run" not "docker exec".

Rickard:

Thanks again for taking your time today to help me out. Another answer 
<https://stackoverflow.com/a/49175304/258825> on my SO question already 
suggested use of "--changes": it is definitely the winning option for me at 
the moment.

However, I would like to use this opportunity to ask if after all there is 
an alternative to "--changes" that can be performed by one of provisioners. 
Reason I'm looking for an alternative is that I'm using Ansible playbook to 
provision both Docker and Vagrant images. My only option for now to set 
PATH correctly in Docker seems to be to duplicate PATH configuration inside 
Packer template and I don't like the idea of repeating the configuration 
for obvious reasons.

I appreciate that this is not an issue with Packer at all, but as mentioned 
earlier, seeing how this forum has a high concentration of people who work 
with Docker without Dockerfiles I was hoping that someone might know a 
better answer (and if not, could perhaps at least hint where the limitation 
lies).


On Thursday, 8 March 2018 19:33:20 UTC+1, Rickard von Essen wrote:
>
> Use changes and ENV to set the PATH, see 
> https://www.packer.io/docs/builders/docker.html#basic-example-changes-to-metadata
>
> On Mar 8, 2018 7:00 PM, "Alvaro Miranda Aguilera" <[email protected] 
> <javascript:>> wrote:
>
>> where packer fits here ?
>>
>> On Thu, Mar 8, 2018 at 6:02 PM, Ivan Ribakov <[email protected] 
>> <javascript:>> wrote:
>>
>>> I'm building a docker image and using Ansible for provisioning. I would 
>>> like to be able to update image's PATH variable from inside the container 
>>> (I don't need these changes to take effect immediately, as long as they are 
>>> commited to an image and are available later). Is there a way to do it?
>>>
>>> To illustrate my point:
>>>
>>> $ docker run -itd --name test centos:6 
>>> $ docker exec -it test /bin/bash 
>>> [root@006a9c3195b6 /]# echo 'echo SUCCESS' > /root/test.sh 
>>> [root@006a9c3195b6 /]# chmod +x /root/test.sh 
>>> [root@006a9c3195b6 /]# echo 'export PATH=/root:$PATH' > 
>>> /etc/profile.d/my_settings.sh 
>>> [root@006a9c3195b6 /]# echo 'PATH=/root:$PATH' > /etc/environment 
>>> [root@006a9c3195b6 /]# echo 'export PATH=/root:$PATH' > ~/.bashrc
>>> [root@006a9c3195b6 /]# exit 
>>> $ docker commit test test-image:1 
>>> $ docker exec -it test-image:1 test.sh
>>> OCI runtime exec failed: exec failed: container_linux.go:296: starting 
>>> container process caused "exec: \"test.sh\": executable file not found in 
>>> $PATH": unknown
>>>
>>>
>>> However, following works:
>>>
>>> $ docker run -it test-image:1 /bin/bash
>>> [root@8f821c7b9b82 /]# test.sh 
>>> SUCCESS
>>>
>>>
>>> Any ideas as to what I'm doing wrong?
>>>
>>> -- 
>>> This mailing list is governed under the HashiCorp Community Guidelines - 
>>> https://www.hashicorp.com/community-guidelines.html. Behavior in 
>>> violation of those guidelines may result in your removal from this mailing 
>>> list.
>>>  
>>> GitHub Issues: https://github.com/mitchellh/packer/issues
>>> IRC: #packer-tool on Freenode
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Packer" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected] <javascript:>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/packer-tool/e4cb8df6-fe4e-48bc-9064-64ce4cabae79%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/packer-tool/e4cb8df6-fe4e-48bc-9064-64ce4cabae79%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Alvaro
>>
>> -- 
>> This mailing list is governed under the HashiCorp Community Guidelines - 
>> https://www.hashicorp.com/community-guidelines.html. Behavior in 
>> violation of those guidelines may result in your removal from this mailing 
>> list.
>>  
>> GitHub Issues: https://github.com/mitchellh/packer/issues
>> IRC: #packer-tool on Freenode
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Packer" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/CAHqq0eyK01mTYLZDQmxdz-U%3DWbFj39dFkcNHEDZ883nXukym9Q%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/CAHqq0eyK01mTYLZDQmxdz-U%3DWbFj39dFkcNHEDZ883nXukym9Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/60a0484d-9850-4046-82b0-0b09152b6447%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to