Public | Automated Build

Last pushed: 2 years ago
Short Description
Complete Docker LAMP Image with Remote Logging and Email Relay
Full Description

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://
  2. 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)
  3. 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

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 \
    -e "DB_USER={MYSQL_USER}" \
    -e "DB_NAME={MYSQL_DB_NAME}" \

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.
Docker Pull Command
Source Repository

Comments (0)