我在window10下使用docker部署mysql5.7。

先上docker-compose.yml

version: '3'
services:
    mysql:
        image: mysql:5.7
        restart: always
        container_name: mysql
        volumes:
        - C:/docker/mysql/conf/my.cnf:/etc/alternatives/my.cnf
        - C:/docker/mysql/data:/var/lib/mysql
        - C:/docker/mysql/logs:/var/log/mysql
        environment:
            MYSQL_ROOT_PASSWORD: root
        ports:
        - 3306:3306

      

目录和配置文件都是存在的,然后使用docker-compose up -d 命令启动

命令行报错:

C:\docker>docker-compose up -d
Recreating 54cbd26d7449_mysql ... error

ERROR: for 54cbd26d7449_mysql  Cannot create container for service mysql: invalid volume specification: 'C:\docker\mysql\conf\my.cnf:/etc/alternatives/my.cnf:rw': invalid mount config for type "bind": source path must be a directory

ERROR: for mysql  Cannot create container for service mysql: invalid volume specification: 'C:\docker\mysql\conf\my.cnf:/etc/alternatives/my.cnf:rw': invalid mount config for type "bind": source path must be a directory
ERROR: Encountered errors while bringing up the project.

C:\docker>

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐