先不映射指定配置目录,./conf/mysql,docker容器开起来后,复制容器内/etc/mysql 到宿主机,然后添加目录映射: -"./conf/mysql:/etc/mysql" ,这样就可以将配置里保存在宿主机了。
version: '3.0'
networks:
mysql_network:
name: mysql_network
external: true
services:
mysql:
image: "mysql:8.0.35"
volumes:
- "./conf/mysql:/etc/mysql"
- "./data:/var/lib/mysql"
- "./logs:/logs"
container_name: "mysql_8_0_35"
# entrypoint: ["docker-entrypoint.sh", "mysqld"]
restart: always
privileged: true
environment:
MYSQL_ROOT_PASSWORD: "your_password"
TZ: "Asia/Shanghai"
ports:
- 3306:3306
networks:
ai_network:
ipv4_address: 192.18.10.100
标签:8.0,compose,network,dokcer,宿主机,etc,conf,mysql
From: https://www.cnblogs.com/jing1024/p/18184235