准备挂载文件
准备文件
docker-compose.yml
# docker-compose --compatibility up -d
version: "3.1"
services:
mysql:
image: mysql:5.7
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: "yourpassword"
MYSQL_USER: 'test'
MYSQL_PASS: 'yourpassword'
restart: always
ports:
- 3306:3306
volumes: #不允许使用'/'根目录,
- /usr/local/mysql/data:/var/lib/mysql
- /usr/local/mysql/my.cnf:/etc/mysql/my.cnf
- /usr/local/mysql/conf.d:/etc/mysql/conf.d
- /usr/local/mysql/mysql.conf.d:/etc/mysql/mysql.conf.d
deploy:
resources:
limits:
memory: 512M
networks:
default:
external:
name: net-xiaodx #使用外部网络,要提前创建 docker network create net-xiaodx --driver bridge
网友评论