A simple docker command to start MySQL on a tmpfs.

Things to note:

  • Mounting localtime affects MySQL server timezone
  • You need to have a my.cnf at the given location ($HOME/docker/mysql/my.cnf)
  • You probably need to create /var/lib/mysql before running the command
  • Setting sql_mode="" is probably not needed for most applications.
sudo docker run -d \
  --name mysql7 \
  -v/usr/share/zoneinfo/Europe/Stockholm:/etc/localtime:ro \
  -v$HOME/docker/mysql/my.cnf:/etc/my.cnf \
  -e MYSQL_ROOT_PASSWORD=root \
  -e MYSQL_ROOT_HOST='%' \
  -p3306:3306 \
  --mount type=tmpfs,destination=/var/lib/mysql \
  mysql/mysql-server:5.7 \
  --sql_mode=""