On Fri, Jul 8, 2016 at 7:49 AM, Sabra Ossen <sa...@wso2.com> 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: sa...@wso2.com
> Mobile: +94 767 837356
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> 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
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to