Rasperri pi 3b+
Installation of the raspberry pi 3b+ is similar to that of the zero. Except you should use the Ubuntu 64bit OS version (version 20 at the moment of writing). This will greatly help you with building dockers. Since there are not much arm32 dockers available on the hub :(. To install it following this guide
Docker / Docker compose
read here what docker is. And read here what docker compose can do. In fact docker compose gives you the ability to ‘manage’ multi container environments. Lets say you want a lamp stack you can manage the moving parts in a single file
Create a custom dockerfile for the php_apache with pdo and mongo connector. It also enabls the mod rewrite for apache because needed it 😉
FROM php:7.4.5-apache
RUN apt-get update
RUN apt-get upgrade -y
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN apt-get install -y openssl libssl-dev libcurl4-openssl-dev
RUN pecl install mongodb-1.6.0
RUN docker-php-ext-enable mongodb.so
RUN a2enmod rewrite
build the docker container
docker build --tag phpapache_custom:latest .
create a yml file to build your environment. This file will start a mariadb, mongodb, apache with php.
the restart always should start the services when your pi rebootes
version: '3'
services:
db:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: <yournicepassword>
volumes:
- <yourlocaldirectoryformysql>:/var/lib/mysql
ports:
- 3306:3306
restart: always
web:
image: phpapache_custom:latest
depends_on:
- db
- mongo
volumes:
- <yourlocaldirectorywww>:/var/www/html/
ports:
- "80:80"
stdin_open: true
tty: true
restart: always
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: <yourmongouser>
MONGO_INITDB_ROOT_PASSWORD: <yourmongopassword>
ports:
- 27017:27017
restart: always
create two bash script to start and stop the composer file. I assume you named your composer file lamp.yml and that there are the following directories in the directory that yml file is in: www, mysql,mongodb
start.sh:
docker-compose -f lamp.yml up -d --build
stop.sh
docker-compose -f lamp.yml down && docker-compose -f lamp.yml rm
write issues in apache
write issues in apache. Because my php application write logs I noticed that it wouldnt run because the user on the docker container doesnt have the correct user rights on the volume that was bound. That seems to be a ubuntu thing? You need to give the group/user www-data the proper rights on the local www directory (of the host system!)
sudo chown -R 33:33 <your local www directory>