0

I'm trying to create an apache + php docker container, but I am getting a build error.

Here's my dockerfile,

FROM ubuntu:14.04

MAINTAINER Mizanur Rahman 

RUN apt-get update
RUN apt-get -y upgrade

RUN apt-get install -y apache2 libapache2-mod-php5 php5-mysql php5-gd php-pear php-apc php5-curl curl lynx-cur php5-intl

RUN a2enmod php5
RUN a2enmod rewrite

RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php5/apache2/php.ini
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php5/apache2/php.ini

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2

EXPOSE 80

# Copy site into place.
ADD www /var/www/site

# Update the default apache site with the config we created.
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf

# By default, simply start apache.
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]

Here's the build output,

Sending build context to Docker daemon 44.23 MB
Sending build context to Docker daemon 
Step 0 : FROM ubuntu:14.04
 ---> fa81ed084842
Step 1 : MAINTAINER Mizanur Rahman <getmizanur@gmail.com>
 ---> Using cache
 ---> 4c5dfddabbc7
Step 2 : RUN apt-get update
 ---> Running in 938037477c9c
Ign http://archive.ubuntu.com trusty InRelease
Ign http://archive.ubuntu.com trusty-updates InRelease
Ign http://archive.ubuntu.com trusty-security InRelease
Err http://archive.ubuntu.com trusty Release.gpg
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-updates Release.gpg
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-security Release.gpg
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Ign http://archive.ubuntu.com trusty Release
Ign http://archive.ubuntu.com trusty-updates Release
Ign http://archive.ubuntu.com trusty-security Release
Ign http://archive.ubuntu.com trusty/main amd64 Packages/DiffIndex
Ign http://archive.ubuntu.com trusty/restricted amd64 Packages/DiffIndex
Err http://archive.ubuntu.com trusty/main Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty/restricted Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty/universe Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty/universe amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-updates/main Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-updates/restricted Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-updates/universe Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-updates/main amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-updates/restricted amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-updates/universe amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-security/main Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-security/restricted Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-security/universe Sources
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-security/main amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-security/restricted amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty-security/universe amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty/main amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com trusty/restricted amd64 Packages
  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/main/source/Sources  Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/t

And finally, here's the error message

The command [/bin/sh -c apt-get update] returned a non-zero code: 100

I have tried few solutions to resolve this issue , and none of them are working for me.

For example,

Docker containers can't resolve DNS on Ubuntu 14.04 Desktop Host

The command [/bin/sh -c apt-get update] returned a non-zero code: 100

Can anyone help me with this? Thanks in advance.

getmizanur
  • 583
  • 1
  • 5
  • 13
  • Avoid `apt-get upgrade` in Dockerfiles, see [best practises](https://docs.docker.com/articles/dockerfile_best-practices/). – OrangeTux Jun 13 '15 at 10:25
  • This points to a networking issue inside the container. Rather than looking at the apt output, we'd need to see the debugging of the networking stack, things like route tables, firewall rules, traceroute, a description of your local network, etc. – BMitch Jul 27 '22 at 13:43

2 Answers2

0

I am on Ubuntu image and the thing which I had to add to Docker file before apt-get update was:

RUN echo Acquire::http::Proxy \"user:pass@proxy.com:port/\"\; >> /etc/apt/apt.conf.d/proxy.conf

This: https://docs.docker.com/config/daemon/systemd/ and this was not enough for apt-get to work:

ENV HTTP_PROXY="http://user:pass@proxy.com:port"

mdev111
  • 1
  • 1
-1

Your problem is related to firewall settings. Execute as root user:

sudo iptables -L -n -v

to list all firewall rules and check FORWARD chain POLICY. It has to be set to to ACCEPT for Docker DNS resolution to work properly.

If it's set to DROP or REJECT, then execute:

sudo ufw disable

If you don't have ufw installed, then execute:

sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
Tomasz Klim
  • 458
  • 5
  • 10
  • Entirely disabling the firewall seems like an unnecessarily heavy-handed way to deal with this... – BE77Y Jun 08 '15 at 15:46
  • Entirely disabling the firewall is the only way to be 100% sure, if the problem is caused by the firewall or not. After that, indeed it would be wise to enable firewall again and just fix its rules. But only in that order. – Tomasz Klim Jun 09 '15 at 13:27
  • It's not the only way - but regardless, you did not make clear in your answer that doing so would merely be temporary, and that it would be crucial to re-enable the firewall after the test. – BE77Y Jun 09 '15 at 13:31
  • Because it's obvious and mentioned in several texts about Docker. Good answer shouldn't repeat advices from manuals. Instead it should be clear, short and let the author go straight to the problem. – Tomasz Klim Jun 09 '15 at 13:40
  • Many good answers repeat text from manuals verbatim, as a matter of fact - and "obviousness" is subjective. Leaving crucial information out makes for a poor answer. – BE77Y Jun 09 '15 at 13:44