Hi Udara,

I tried method #2 and when I checked the running container created from the
built image, but the host entry was not added. Method #2 only works when I
set the host entry and then use the host entry in the same line, as I have
shown above. Any RUN command executed after the above RUN command would
create a new intermediate container thus creating a new /etc/hosts file.

Thanks and Regards.


On Fri, Jul 8, 2016 at 5:42 PM, Udara Liyanage <[email protected]> wrote:

>
>
> On Fri, Jul 8, 2016 at 7:49 AM, Sabra Ossen <[email protected]> wrote:
>
>> Hi All,
>>
>> I am trying to add a host entry to /etc/hosts inside of a docker image
>> built from a dockerfile. An extensive search resulted in the following
>> results.
>>
>> 1. Add the host entry at runtime using command,
>>     *docker run -it --add-host myhost:192.168.18.2 <image-id> /bin/bash*
>>     This method only makes the host entry available in the running
>> container and not in the image resulting after a docker build.
>> 2. Add "RUN echo "192.168.11.112 myhost" >> /etc/hosts && wget
>> http://myhost"; to the docker file. With each RUN command a new
>> intermediate container will be created. This method only allows the host
>> entry available in the intermediate container.
>>
> I think this method will work.
> What do you mean by available only to   intermediate container. If you add
> above RUN command it will persist in the final docker image, isn't it?
>
>>
>> Many methods allow the host entry to be available only from a container
>> level vs image level. Any known clean method for $subject.
>>
>> Thanks and Regards.
>> --
>> *Sabra Ossen*
>> *Software Engineer*
>> Email: [email protected]
>> Mobile: +94 767 837356
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
>
> Udara Liyanage
> Software Engineer
> WSO2, Inc.: http://wso2.com
> lean. enterprise. middleware
>
> web: http://udaraliyanage.wordpress.com
> phone: +94 71 443 6897
>



-- 
*Sabra Ossen*
*Software Engineer*
Email: [email protected]
Mobile: +94 767 837356
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to