Lightweight LAMP stack with domain whitelist, multi-arch support, and phpMyAdmin.
543
This Docker image provides a LAMP stack (Linux, Apache, MySQL, PHP) with additional security features, built from scratch on Alpine Linux.
Source: Based on j1cs/docker-lamp with enhancements:
✅ Whitelist domain filtering
✅ Multi-architecture support
✅ Optimized logging to docker logs
✅ Persistent data volumes
mod_rewrite enabledstdout/stderr for easy viewing with docker logsamd64, ARM64 (e.g., STB Armbian HG680P), and VM environmentsctype, curl, dom, gd, iconv, intl, json, mbstring, mcrypt, mysqli, opcache, pdo_mysql, phar, session, tokenizer, xml, zip, zlibdocker pull rizkybs70/docker-lamp:latest
git clone https://github.com/rizkybs70/docker-lamp
cd docker-lamp
docker build -t docker-lamp .
docker run -d \
--name=docker-lamp \
-e MYSQL_ROOT_PASSWORD=yourpassword \ # Change this!
-e ALLOWED_DOMAIN="example.com,test.org" \ # Optional: restrict to these domains
-p 80:80 \
-p 3306:3306 \
-v /path/to/website:/var/www/localhost/htdocs \
-v /path/to/mysql-data:/var/lib/mysql \
--restart unless-stopped \
rizkybs70/docker-lamp:latest
Explanation of options:
-e MYSQL_ROOT_PASSWORD=yourpassword – Set the MySQL root password (required).-e ALLOWED_DOMAIN="example.com,test.org" – Comma‑separated list of allowed domains (optional). If omitted or empty, no domain restriction is applied.-p 80:80 – Expose HTTP port.-p 3306:3306 – Expose MySQL port.-v /path/to/website:/var/www/localhost/htdocs – Mount your website files.-v /path/to/mysql-data:/var/lib/mysql – Persist MySQL data.--restart unless-stopped – Auto‑restart policy.The ALLOWED_DOMAIN environment variable lets you restrict HTTP access to specific domain names.
"example.com,test.org". Spaces after commas are ignored.www variants are automatically permitted (e.g., if you allow example.com, both example.com and www.example.com are accepted).http://192.168.1.100) and localhost are always permitted, regardless of the whitelist.ALLOWED_DOMAIN is not set or is empty, the container behaves like a normal LAMP stack – all domains are allowed.How it works:
The script generates an Apache RewriteRule that blocks requests with a Host header not matching the allowed domains (or IP/localhost). Blocked requests receive a 403 Forbidden response.
All Apache access and error logs are sent to the container’s stdout/stderr. View them with:
docker logs docker-lamp
Example access log line:
192.168.1.10 - - [03/Mar/2026:12:00:00 +0000] "GET /index.php HTTP/1.1" 200 1234 "-" "Mozilla/5.0 ..."
Simply set MYSQL_ROOT_PASSWORD to your desired password.
To generate a random password on each start, use -e MYSQL_RANDOM_ROOT_PASSWORD=yes – the generated password will be printed in the logs.
/var/www/localhost/htdocs/var/lib/mysqlImportant: Ensure the mounted directories have proper permissions. The container runs Apache as user apache (UID 100) and MySQL as user mysql (UID 100). If you encounter permission errors, adjust ownership:
sudo chown -R 100:100 /path/to/website
sudo chown -R 100:100 /path/to/mysql-data
http://<host-ip>http://<host-ip>/phpmyadmin (login with root and your MySQL password)mysql -h <host-ip> -P 3306 -u root -p
After building the image, you can free disk space by removing unused build cache:
docker builder prune -f
Original project by j1cs/docker-lamp.
Modifications for domain whitelist, multi‑arch support, and enhanced logging by rizkybs70.
MIT
Content type
Image
Digest
sha256:20dbcfd51…
Size
98.6 MB
Last updated
7 months ago
docker pull rizkybs70/docker-lamp