On this Docker I try to install a web server on which I will put websites and databases. I chose to do this because I will need access to databases from a JAVA application. Something that would not be possible if I had chosen a simple web host instead of this virtual server. The issue is when i run the docker-compose: docker-compose up -d. Choose one of the below content for your Dockerfile in regards to web server. To Use Nginx Web server. FROM nginx COPY. /usr/share/nginx/html To Use Apache Web server. FROM apache COPY. /var/www/html Based on the comparison about Apache vs Nginx to run static site. We prefer to go with the Nginx web server. Build Docker Image.
- Docker Compose Apache Web Server Free
- Docker Compose Apache Web Server Login
- Docker Compose Execute Command
- We use docker-compose to configure services for each app. For this article, let’s assume we use apache2 as an HTTP server for both host and container. On the main server (host) you would probably prefer Nginx, but we’ll stick with apache for presentation purposes. Each HTTPS request will hit our host server.
- Starting with Docker Compose We will be using Docker Compose to set up an environment with two docker containers: a webserver with Apache and PHP and a database server with MySQL. This is a frequent recurring scenario and opens the door for experimenting with Wordpress, PHP frameworks.
- Command to install Docker Engine: How To Start Apache Web Server i.
- Docker Tutorial
- Docker Useful Resources

- 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.
Step 2 − Run the Docker build command to build the Docker file. It can be done using the following command −
Docker Compose Apache Web Server Free
We are tagging our image as mywebserver. Once the image is built, you will get a successful message that the file has been built.
Docker Compose Apache Web Server Login
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 −
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 Compose Execute Command
If you go to port 80 of the Docker host in your web browser, you will now see that Apache is up and running.
