version: '3'标签:mysql,cmd,db,conf,MYSQL,test,docker From: https://www.cnblogs.com/SunshineKimi/p/17078359.html
services:
db:
#构建mysql镜像
image: mysql
networks:
network1:
ipv4_address: 172.16.238.10
ipv6_address: 2001:3984:3989::10
container_name: mysql-db # 容器名
restart: always
environment:
MYSQL_ROOT_PASSWORD: root #root管理员用户密码
MYSQL_USER: test #创建test用户
MYSQL_PASSWORD: test #设置test用户的密码
ports:
- '3310:3306'
volumes:
- /tmp/docker/mysql/data/db:/var/lib/mysql
- /tmp/docker/mysql/data/conf:/etc/mysql/conf.d