This will create a stateful MySQL instance in Docker.
- The database files are stored in ./database_files
- The configuration files are stored in ./config
- The default username is ‘root’
- The default password is specified on the command line
- The default port is 3306
1
2
3
4
5
mkdir -p ${PWD}/database_files
mkdir -p ${PWD}/config/conf.d
docker run --name mysql -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 \
-v ${PWD}/database_files:/var/lib/mysql/ -v ${PWD}/config:/etc/mysql \
-d mysql
Stateful = If you create the mounted volumes around (-v), every time you start the pod, the databases and config files will be loaded into the pod maintaining the “state” of the pod instance.