Docker Ubuntu Apache2



  1. I want to install certbot in a docker environment with an Ubuntu 16.04 image. For example: docker run -it ubuntu:16.04 /bin/bash When I'm inside the container, the most straightforward way to install certbot does not work as it requires user intervention.
  2. In my case, I have a PHP web application being served by Apache2 within the docker container that connects to a MYSQL backend database. Larry Cai's solution worked with minor modifications. I created a entrypoint.sh file within which I am managing my services.
  • Docker Tutorial
  • Docker Useful Resources

So the Ubuntu server – docker – reverse proxy needs to be reconfigured to be able to operate. Office.domain.yx:4433 would be my choice that could be forwarded through the router / firewall do i have to adapt in apache2 / collabora and?

Apache2
  • Selected Reading

We have already learnt how to use Docker File to build our own custom images. Now let’s see how we can build a web server image which can be used to build containers.

In our example, we are going to use the Apache Web Server on Ubuntu to build our image. Let’s follow the steps given below, to build our web server Docker file.

Step 1 − The first step is to build our Docker File. Let’s use vim and create a Docker File with the following information.

The following points need to be noted about the above statements −

  • We are first creating our image to be from the Ubuntu base image.

  • Next, we are going to use the RUN command to update all the packages on the Ubuntu system.

  • Next, we use the RUN command to install apache2 on our image.

  • Next, we use the RUN command to install the necessary utility apache2 packages on our image.

  • Next, we use the RUN command to clean any unnecessary files from the system.

  • The EXPOSE command is used to expose port 80 of Apache in the container to the Docker host.

  • Finally, the CMD command is used to run apache2 in the background.

Now that the file details have been entered, just save the file.

Docker Ubuntu Apache2

Dockerfile Apache2 Ubuntu 18.04

Step 2 − Run the Docker build command to build the Docker file. It can be done using the following command −

Dockerfile Apache2 Ubuntu 16.04

We are tagging our image as mywebserver. Once the image is built, you will get a successful message that the file has been built.

Step 3 − Now that the web server file has been built, it’s now time to create a container from the image. We can do this with the Docker run command.

The following points need to be noted about the above command −

Docker Ubuntu Apache Enable Rewrite

  • The port number exposed by the container is 80. Hence with the –p command, we are mapping the same port number to the 80 port number on our localhost.

  • The –d option is used to run the container in detached mode. This is so that the container can run in the background.

Docker Ubuntu Apache Php7

If you go to port 80 of the Docker host in your web browser, you will now see that Apache is up and running.