Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose on Windows volume not working

I've been playing with Docker for the past week and think the container idea is very useful, but despite reading everything I can for the past 3 days I can't get the volume mapping to work

get docker-compose to use my existing volume.

    Docker Version: 18.03.1-ce
    docker-compose version 1.21.1, build 7641a569

I created a volume using the following via a Dockerfile

    # Reference SQL image
    FROM microsoft/mssql-server-windows-developer

    # Create directory within SQL container for database files mapped to the    volume
    VOLUME sqldata:c:/MSSQL

and here it shows:
    C:\ProgramData\Docker\volumes>docker volume ls
    local               sqldata

Now I've tried probably 60+ different "solutions" based on StackOverflow and Docker forums, but none of them work. (Note despite the names below with Azure I am simply trying to get this to run locally, Azure is next hurdle)

    Docker-compose.yaml:

    version: '3.4'
    services:
      ws:
        image: wsManager
        container_name: azure-wcf
        ports:
           - "80"
        depends_on:
            - db

      db:
        image: dbimage:latest
        container_name: azure-db
        volumes:
             - \sqldata:/mssql
#            - type: volume
#              source: sqldata
#              target: /mssql
        ports:
            - "1433"

I've added a volumes section but it does not help, 

    volumes:
        sqldata:
            external:
                name: sqldata

    changed the - \sqldata:/mssql
    to every possible slash .. . ~ whatever.  Moved the file to yaml file 

to C:\ProgramData\Docker\volumes - basically any suggestion that showed in my search results. The dbImage is a SQL Server image that I need to persist the data from but am wondering what the magic is as nothing I've tried works. Any help is GREATLY appreciated.

I'm running on Windows 10 Pro build 1803.

Why does this have to be so hard? Than you to whomever knows how to make this actually work.

like image 578
Maui_Ed Avatar asked Jun 21 '18 02:06

Maui_Ed


1 Answers

By default it looks that after installing Docker on Windows, sharing of drivers is disabled - so you won't be able to use volumes(that are stored on disks)

Enabling such sharing, through: Docker in tray - right click - Settings, helped to me, volumes started working fine. enter image description here

like image 144
Oleksandr Yefymov Avatar answered Oct 27 '22 12:10

Oleksandr Yefymov