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: ecpm volumes: #数据目录,要确保先创建好 - ./data/mysql/data:/var/lib/mysql - ./data/mysql/logs:/var/log/mysql ##初始化的脚本,初始化我们存放的init.sql文件 - ./data/sql:/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 redis: image: redis restart: always hostname: redis container_name: redis privileged: true ports: - "6379:6379" environment: TZ: Asia/Shanghai volumes: - ./data/redis:/data # - ./conf/redis.conf:/etc/redis/redis.conf - ./data/redis/logs:/logs # command: [ "redis-server","/etc/redis/redis.conf" ]