Docker Community Forums

Share and learn in the Docker community.

Error building on EC2

I’m just getting started with Docker so apologies if I’m doing something stupid! I’m following this YT guide on creating a simple hello world container on AWS EC2 - https://www.youtube.com/watch?v=VRWTtVreEM8

This is my Dockerfile:

FROM unbuntu:18.04

# Install dependencies
RUN apt-get update -y
RUN apt-get install -y apache2

# Install apached and write hello world message
RUN echo "Hello world" > /var/www/index.html

# Configure apache
RUN a2enmod rewrite
RUN chown -R www-data:www-data /var/www
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2

EXPOSE 80

CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]

I’m using the command:
docker build -t hello-world .
But this is failing with the following error:

Sending build context to Docker daemon  9.216kB
Step 1/13 : FROM unbuntu:18.04
pull access denied for unbuntu, repository does not exist or may require 'docker login'

I’ve logged in successfully with docker login and I’ve also tried setting ARGuments in the Dockerfile but nothing seems to work.

Can anyone help? like I said, I’m probabaly doing something stupid!

I’d assume that unbuntu should be ubuntu

@jedihomer oh for gods sake!!! I knew it would be something stupid!

I have built the image now, but when I run it docker run -p 80:80 hello-world I’m getting another error:

[Wed Jul 31 13:26:54.340398 2019] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

Pressumably I need to set the APACHE_RUN_DIR in the Dockerfile, how would I do that?

I’ve not really played with Apache in Docker, but I would assume you can/would set it as an environmental variable similar to how you’ve done APACHE_LOG_DIR etc.