version: "3" services: mysql: image: mysql container_name: mysql restart: always command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', '--explicit_defaults_for_timestamp=true', '--lower_case_table_names=1' ] environment: MYSQL_ROOT_PASSWORD: youtu!0113 MYSQL_INITDB_SKIP_TZINFO: "Asia/Shanghai" #MYSQL_DATABASE: data_sys volumes: #数据目录,要确保先创建好 - ./data/mysql/data:/var/lib/mysql - ./data/mysql/logs:/var/log/mysql ##初始化的脚本,初始化我们存放的init.sql文件 - ./data/mysql/initdb:/docker-entrypoint-initdb.d/ - ./data/mysql/conf:/etc/mysql/conf.d ports: - "3306:3306" healthcheck: test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-uyoutu", "-pyoutu!0113" ] interval: 6s timeout: 5s retries: 10 #network_mode: host