Docker how to start container with defined nameservers in /etc/resolv.conf

Meiram Chuzhenbayev picture Meiram Chuzhenbayev · Apr 28, 2016 · Viewed 16.9k times · Source

Here is my Dockerfile

FROM javamachine_0.1.2
MAINTAINER Meiram
RUN /report/report.sh start
ENV LANG C.UTF-8 ENV LANGUAGE C.UTF-8 ENV LC_ALL C.UTF-8
RUN echo "nameserver 192.168.1.100" > /etc/resolv.conf
COPY resolv.conf /etc/resolv.conf
EXPOSE 9090

when creating container directive docker run --dns also do not change entries in /etc/resolv.conf

How to change entries in /etc/resolv.conf permanently?

Answer

harunyardimci picture harunyardimci · Apr 28, 2016

if you use --dns you may need to remove those lines:

RUN echo "nameserver 192.168.1.100" > /etc/resolv.conf
COPY resolv.conf /etc/resolv.conf

also,

try to swap the lines too.. COPY command will override the previous one.