赞
踩
docker pull mysql:5.7
docker images
mkdir -p /root/mysql/data /root/mysql/logs /root/mysql/conf
在 /root/mysql/conf 目录下创建 mysql 配置文件。
touch my.cnf
version: "3"
services:
mysql_5.7:
image: mysql:5.7
container_name: mysql_5.7
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- "/root/mysql/conf:/etc/mysql/conf.d"
- "/root/mysql/logs:/logs"
- "root/mysql/data:/var/lib/mysql"
restart: always
privileged: true
进入 docker-compose.yaml 同级目录下,执行启动命令。
docker-compose up -d
PS:如果出现 **Error response from daemon: Mounts denied:**说明映射本地文件失败,打开 docker desktop -> settings -> resource -> file sharing,添加映射的本地目录共享。
docker ps
编辑 /root/mysql/conf/my.cnf 即可。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。