Ubuntu 16.04 Docker Image

Running Apache 2 under Ubuntu 16.04 on Docker

By : Josh -

Running Docker Nginx in Detached Mode: First, remove the old Nginx container and then create a new, detached Nginx container by using below commands. $ sudo docker rm docker-nginx. $ sudo docker run -name docker-nginx -p 80:80 -d nginx. Whereas the -d is being used to run this container in the background.

I recently wanted to setup a new Ubuntu 16.04 host running Apache under Docker for some AWS ECS/Fargate testing I was doing and encountered the following error:

This is a typical Ubuntu problem where the /etc/apache2/envvars file needs to be sourced before apache2 can start properly. To figure out which ones needed to be added, I commented out the CMD to start apache and instead entered a command to print out the contents of the envvars file. I also added a sed command to print out line 74 of the apache2.conf file so I could further troubleshoot what was happening there.

  1. Ubuntu is a Debian-based Linux operating system that runs from the desktop to the cloud, to all your internet connected things. It is the world's most popular operating system across public clouds and OpenStack clouds. It is the number one platform for containers; from Docker to Kubernetes to LXD, Ubuntu can run your containers at scale.
  2. Using a PuTTy session will just make copy/pasting commands into your uBuntu VM easier. Now you’ll install docker – the package includes both the docker server and client. Run the commands above in sequence, and after the apt-get install docker-engine at the end, run ‘sudo service docker status’ to check that docker is running.

This output showed that I had to add a few environment variables to the Dockerfile, and verify that they exist when I run the container:

What Is Docker

I also verified that the directories would exist to prevent any issues there:

After I finished that, I rebuilt the image and was able to run the container without issues.

Ubuntu 16.04 Docker Image

The full Dockerfile is:

Ubuntu 16.04 Docker Image

Docker Container

Build the container image:

Run the container:

UPDATE: it looks like James Turnbull had already solved this problem here.

Most Viewed Posts