Mysql
mkdir -p /root/mysql/logs /root/mysql/data
# 先起一个mysql,把/etc/mysql中的配置文件拷贝出来
docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql
docker cp mysql:/etc/mysql /root/mysql
docker stop mysql
docker rm mysql
docker run \
-d -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 \
--name mysql --restart unless-stopped \
-v /root/mysql/data:/var/lib/mysql \
-v /root/mysql/mysql:/etc/mysql \
-v /root/mysql/logs:/logs mysql \
--lower_case_table_names=1 \
--default-authentication-plugin=mysql_native_password
5.7
mkdir /root/mysql/log /root/mysql/data /root/mysql/conf
docker run \
--name mysql \
-d \
-p 3306:3306 \
--restart unless-stopped \
-v /root/mysql/log:/var/log/mysql \
-v /root/mysql/data:/var/lib/mysql \
-v /root/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:5.7