Dockerized mysql server ready to deploy on raspberry pi.
This will create a MySQL 5.7 container (which runs on arm32v7, arm64v8, and amd64) with the name rpi_mysql.
- Configure the
MYSQL_ROOT_PASSWORD
environment variable. - Place any configurations as .cnf files under
config
. The directory will be mounted to/etc/mysql/conf.d
. - Place any scripts to run inside the container under
scripts
. In order to run a script automatically, place it underscripts/init
.
Then, run:
$ docker build -t rpi_mysql .
$ docker-compose up -d
The docker container automatically restarts upon reboot. (Do not terminate the process before shutdown)
Otherwise, run:
$ docker-compose up -d
To connect to the mysql instance using the mysql command, run:
$ docker exec -it <instance_name> mysql -u root -p
(To check the instance name, run docker ps
)
$ docker exec -it <instance_name> mysql -e <command> -u root -p