Complete Docker LAMP Image with Remote Logging and Email Relay
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

LAMP on Docker

How to use

Available in the docker registry under castawaylabs/lamp-docker

Manual build:

  1. docker build -t CastawayLabs/lamp-docker git://


  1. Make directories for your website files. We use the following setup:
  • mkdir -p /home/websites/
  • chmod 750 /home/websites
  • chown root:root /home/websites
  • Nginx routing host:80 to a port opened by docker (see below)
  1. Run the docker image
  • If you have a mysql instance running, and want to link it to the container, see section below.
  • docker run -d --name "" --hostname "" -p 8080:80 -v /home/websites/ CastawayLabs/lamp-docker
  1. There is no step 3. See below for additional configuration

Linking MySQL

Run a mysql instance, make sure to name it 'mysql' or similar.

docker run -d --name "" \
	-p 8080:80 \
	-v /home/websites/ \
	--link mysql:db \

In your PHP script, access those variables using:

$db_name = getenv('DB_NAME');
$db_pass = getenv('DB_PASS');
$db_user = getenv('DB_USER');
$db_host = getenv('DB_PORT_3306_TCP_ADDR');

Sending Email

This image is configured to relay mail through mandrill. (contribute to add other mail relays).

Add the following environment variables when starting the image:



An interesting topic with docker, we've solved it by sending the log files to papertrail. Setting a hostname will ensure you know which log container to look at when required, and not having to dig around with docker cp etc.

Set this environment variable to enable logging:

  • RSYSLOG=*.*

Tips and tricks

  • Export log files from docker: docker cp domain.com_logs
  • Look for messages at boot for diagnostics. It will say something about mandrill if its enabled, and something about RSYSLOG when you enable logging.