Two steps to run a LAMP system on a Raspberry Pi:
- Create a Dockerfile for the webserver with PHP. Add all PHP plugins etc. which are necessary. In the example, MySQL extensions are added
- A Docker Compose file fires up the webserver image and a MySQL image. The one which is used in the example (“jsurf/rpi-mariadb:latest”) is a special MySQL image for the Raspberry architecture.
The Dockerfile:
FROM php:7.4-apache RUN docker-php-ext-install mysqli pdo pdo_mysql RUN docker-php-ext-enable mysqli
The Docker Composefile:
version: "3" services: mariadb: image: jsurf/rpi-mariadb:latest environment: - "MYSQL_ROOT_PASSWORD=pwd" volumes: - /home/pi/apache/mysql/:/var/lib/mysql ports: - 3306:3306 expose: - 3306 apache: image: tom/webserver:2 volumes: - /home/pi/apache/data:/var/www/html expose: - 80 ports: - 80:80