source: https://www.docker.com/blog/how-to-use-the-apache-httpd-docker-official-image/
Small Docker container
This will build a small instance of the Apache webserver. Good for very simple web sites requiring very little configuration.
1
2
3
4
5
6
mkdir webroot
echo "Hello." > webroot/index.html
docker run -d --name my-apache-app -p 8080:80 -v $(pwd)/webroot:/usr/local/apache2/htdocs/ httpd:2.4
IP=$(hostname -I | cut -d " " -f 1)
echo "Your website is at https://$IP:8080"
To stop and remove the Docker container you just made:
1
2
docker stop my-apache-app
docker rm my-apache-app
Larger Ubuntu container that installs Apache
source: https://www.digitalocean.com/community/tutorials/apache-web-server-dockerfile
Dockerfile:
1
2
3
4
5
6
7
FROM ubuntu
RUN apt-get update
RUN apt-get -y install apache2
RUN apt-get -y install apache2-utils
RUN apt-get clean
EXPOSE 8080
CMD [“apache2ctl”, “-D”, “FOREGROUND”]
Build:
1
docker build --tag ubuntu-apache-image .
Run:
1
docker run -d --name my-apache-app -p 8080:80 -v $(pwd)/webroot:/var/www/html/ ubuntu-apache-image
Stop and Delete:
1
2
docker stop my-apache-app
docker rm my-apache-app