Start a simple web server with mounted document root

Go to Project 1 from the git repository root:

cd projects/p01

Project structure:

.
└── www
    └── index.html

This project contains only one folder, “www” and an index.html in it with the following line:

Hello Docker (p01)

Start the container and mount “www” as document root:

docker run -d -v $(pwd)/www:/usr/local/apache2/htdocs:ro --name p01_httpd -p "8080:80" httpd:2.4
# or
docker run -d --mount type=bind,source=$(pwd)/www,target=/usr/local/apache2/htdocs,readonly --name p01_httpd -p "8080:80" httpd:2.4

Generate a domain name:

xip
# example output:
# 192.168.1.2.xip.io

Test the web page:

http://192.168.1.2.xip.io:8080

Now you should see the content of the mounted index.html

Delete the container to make port 8080 free again.

docker rm -f p01_httpd