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:
nip.sh
# example output:
# 192.168.1.2.xip.io
In case are working in the cloned repository of this tutorial, you can also run the below command to set the variable
../../system/usr/local/bin/nip.sh
Test the web page:
http://192.168.1.2.nip.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