由于Windows Server 2019上的无效卷规格,Docker-compose up无法为服务mysql创建容器

时间:2020-10-26 09:52:47

标签: docker docker-compose docker-volume windows-server-2019

我现在有一台安装了系统Windows Server 2019 Standard 64-bit的服务器。我已启用Linux容器,以便从Docker Hub中提取Mysql映像。参数COMPOSE_CONVERT_WINDOWS_PATHS现在值1

我写的docker-compose file如下:

version: '3'

services: 
    mysql:
        container_name: EE
        environment:
            MYSQL_ROOT_PASSWORD: "demo"
        command: 
            --character-set-server=utf8
        ports: 
            - 33065:3306
        image: "docker.io/mysql:5.7.16"
        volumes: 
            - "./db:/var/lib/mysql"
            - "./init:/docker-entrypoint-initdb.d/"

我得到了错误:

ERROR: for EE  Cannot create container for service mysql: invalid volume specification: '/c/Users/Public/Documents/SharedDrive_NWServer/zih/EE/db:/var/lib/mysql:rw'

ERROR: for mysql  Cannot create container for service mysql: invalid volume specification: '/c/Users/Public/Documents/SharedDrive_NWServer/zih/EE/db:/var/lib/mysql:rw'

但是在装有Windows 10系统的笔记本电脑中,一切正常。

我也尝试使用绝对路径更改卷:

volumes: 
        - "C:/Users/Public/Documents/SharedDrive_NWServer/zih/EE/db:/var/lib/mysql"
        - "C:/Users/Public/Documents/SharedDrive_NWServer/zih/EE/init:/docker-entrypoint-initdb.d/"

但是出现相同的错误。

我刚刚尝试了命名卷:

version: '3'

services: 
    mysql:
        container_name: EE
        environment:
            MYSQL_ROOT_PASSWORD: "demo"
        command: 
            --character-set-server=utf8
        ports: 
            - 33065:3306
        image: "docker.io/mysql:5.7.16"
        volumes: 
            - db_path:${DB_DESTINATION_PATH}
            - init_path:${INIT_DESTINATION_PATH}

volumes:
    db_path:
        driver: local
        driver_opts:
            device: ${DB_PATH}
    init_path:
        driver: local
        driver_opts:
            device: ${INIT_PATH}

它显示了错误:

Creating volume "ee_db_path" with local driver
ERROR: create ee_db_path: options are not supported on this platform

我还可以采取什么其他方法来解决问题?

0 个答案:

没有答案