I want to add a domain entry to /etc/resolv.conf
of my docker container.
Here is my dockerFile
FROM tomcat:8.0.20-jre7
VOLUME /tmp
#RUN sed -i "s|search local|domain com.example.com|g;" /etc/resolv.conf
RUN echo "domain com.example.com" >> /etc/resolv.conf
# Expose ports.
EXPOSE 8080
I tried both echo
and sed
.
with sed
, I get error during build.
sed: cannot rename /etc/sed6LcoES: Device or resource busy
but with echo
container build and run successfully.
however, when I get into container, I do not see my domain added in /etc/resolv.conf
.
why is it not working?
NOTE: I have got dns-search
working by passing during run argument
docker run -p 8080:8080 --dns-search=com.example.com -d --name myawesome my/myawesome:latest
but I am interested in getting dockerFile working.
This is by design.
/etc/resolv.conf
is used by docker engine to handle service discovery. Documentation states the following:If you want to override/reconfigure some dns settings, use
--dns
parameters during container starting. See more details: