Lighttpd is a web server for serving web content to clients. Lighttpd is an open-source project released under the 3-clause BSD license.
This tutorial explains how to install Lighttpd inside a Docker container in the Linux. Commands have been tested on Ubuntu.
Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.
- Host network
Run the following command to create a container for Lighttpd that uses host network:
docker run -t -d --name=lighttpd --restart=always --network=host \ -v /var/www:/var/www/localhost/htdocs \ sebp/lighttpd
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, Lighttpd service is listening on port 80. It can be changed with
docker network create app-net
docker run -t -d --name=lighttpd --restart=always --network=app-net \ -p 8080:80 \ -v /var/www:/var/www/localhost/htdocs \ sebp/lighttpd
index.html for testing:
echo '<!DOCTYPE html><html><head><title>Title</title></head><body>Hello world</body></html>' | sudo tee /var/www/index.html
Open a web browser and go to
<IP_ADDRESS> is the IP address of the system. You will see a recently created page.
To completely remove Lighttpd, remove its container and associated volume:
docker rm --force --volumes lighttpd
Remove Lighttpd image:
docker rmi sebp/lighttpd
You can also remove Lighttpd web data:
sudo rm -rf /var/www
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net