I have problem running any command requiring internet connection within my Dockerfile script (like calling apt-get install xyz
), probably due to DNS problems.
I've already read this thread and added --dns 8.8.8.8 --dns 8.8.4.4
to DOCKER_OPTS
. Unfortunately, it didn't help at all, still having issues connecting.
The only solution that works so far is to add the following line to my Dockerfile:
RUN 'echo nameserver 8.8.8.8 > /etc/resolv.conf'
It works, but it's cluttering the Dockerfile a little bit.
I also tried to edit /etc/resolv.conf
on my main machine, but it didn't help.
Any suggestions? I'm running Ubuntu 14.04, kernel 3.13.0-35
// edit:
Here's the gradle script to generate Dockerfile:
task createDockerfile(type: Dockerfile) {
dependsOn build
destFile = project.file('build/Dockerfile')
from 'java:8'
volume '/tmp'
runCommand 'echo nameserver 8.8.8.8 > /etc/resolv.conf'
runCommand 'apt-get update'
runCommand 'apt-get install -y rabbitmq-server'
runCommand 'service rabbitmq-server start'
addFile 'libs/notification-bc-*.jar', 'notification-bc.jar'
runCommand 'bash -c "touch /notification-bc.jar"'
entryPoint 'java', '-jar', '/notification-bc.jar'
}
and the resulting Dockerfile iteslf:
FROM java:8
VOLUME ["/tmp"]
RUN echo nameserver 8.8.8.8 > /etc/resolv.conf
RUN apt-get update
RUN apt-get install -y rabbitmq-server
RUN service rabbitmq-server start
ADD libs/notification-bc-*.jar notification-bc.jar
RUN bash -c "touch /notification-bc.jar"
ENTRYPOINT ["java", "-jar", "/notification-bc.jar"]