Public Repository

Last pushed: 12 days ago
Short Description
An open-source web server optimized for speed-critical environments
Full Description

lighttpd

Derived from the "port" by Adam Miller maxamillion@fedoraproject.org from https://github.com/fedora-cloud/Fedora-Dockerfiles
Originally written for Fedora-Dockerfiles by Stephen Tweedie sct@redhat.com

dockerfiles-clefos-lighttpd

ClefOS 7 dockerfile for lighttpd (http://www.lighttpd.net/)

Configuration


You should prepare SSH public key so you'll be able to login to the container (sshd config denies login to any
other user):

ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): /tmp/lighttpd/.ssh/id_dsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /tmp/lighttpd/.ssh/id_dsa.
Your public key has been saved in /tmp/lighttpd/.ssh/id_dsa.pub.
The key fingerprint is:
46:ee:f2:38:14:1d:da:72:13:b6:8a:ee:56:6f:f1:f1 root@docker.devlab.sinenomine.net
The key's randomart image is:
+--[ DSA 1024]----+
|                 |
|        +        |
|       =.+       |
|      +o*        |
|     . =S.       |
|    . +o. .      |
|   . o...o o     |
|    o .+o . E    |
|   o. .o.        |
+-----------------+

Change the ownership of the public key file to that of the running container. e.g.

chown 999:998 /tmp/lighttpd/.ssh/id_dsa.pub
chown 999:998 /tmp/lighttpd.ssh

Installation


Prepare directories for logs and configs and htdocs:

$ mkdir /srv/docker_mounts/lighttpd/{logs,configs,htdocs} -p

If you have prepared lighttpd.conf you can put it now in
/srv/docker_mounts/lighttpd/configs (this dir will be mounted as
/etc/lighttpd in the container). If not than the default will be generated and
used by lighttpd daemon.

Clone Dockerfile somewhere and build the container:

$ sudo docker build -t lighttpd:centos7 --rm .

Take note of ssh lighttpd user password during above build process - you'll
need that later:

Step 17 : RUN /root/scripts/init.sh
...
lighttpd ssh password: uk3pieWi

And now run the container:

On docker 1.8.0+:
$ sudo docker run -d -p 8091:80/tcp -v /srv/docker_mounts/lighttpd/configs:/etc/lighttpd -v /srv/docker_mounts/lighttpd/logs:/var/log/lighttpd -v /srv/docker_mounts/lighttpd/htdocs/:/srv/httpd/htdocs -v /tmp/lighttpd/.ssh/id_dsa.pub:/home/lighttpd/.ssh/authorized_keys --name=lighttpd -t lighttpd:centos7

In above example params means:

  • -p 8091:80/tcp - let's forward external 8091 port from host to container port 80
  • -v /srv/docker_mounts/lighttpd/logs:/var/log/lighttpd:rw - mounting host
  • /srv/.../logs dir in container's /var/log/lighttpd dir with rw rights
  • -v /tmp/lighttpd/.ssh/id_dsa.pub:/home/lighttpd/.ssh/authorized_keys - map a public key to the lighttpd authorized_keys file

After running container it should be working fine and you should be able to ssh
to it using ssh key that you can map using the identity created above (/tmp/lighttpd/.ssh/id_dsa).

Testing


Just try accessing some webpage (did you generate and put any in the htdocs
dir?). First let's check container IP:

$ sudo docker inspect -format '{{ .NetworkSettings.IPAddress }}' container_id

And next use use links:

$ links http://@container_IP_ADDR/index.html

Also try to ssh to the container with lighttpd user:

$ ssh -i /tmp/lighttpd/.ssh/id_dsa lighttpd@container_IP

Seeing only 404 error? Probably you didn't put any index.html into htdocs dir.
Also remember that default lighttpd config expects htdocs/lighttpd as the
public directory so you should create e.g. htdocs/lighttpd/index.html file

Managing configuration:


In order to change configuration just edit cfg files in host
/srv/docker_mounts/lighttpd/configs (remember that this dir is mounted on
/etc/lighttpd/ in container) and run a command:

$ ssh lighttpd@container_IP "sudo /etc/init.d/lighttpd restart"

Managing logfiles


You can access logfiles within host in /srv/docker_mounts/lighttpd/logs; those logs
are rotated by containers logrotate.

Docker Pull Command
Owner
sinenomine

Comments (0)