title: Docker compose how to initialize SQL Server DB on Windows container?
body: <p>I run <strong>docker for Windows 18.03 on Windows 10</strong>. I use the <strong>microsoft/mssql-server-windows-express</strong> (from Windows Server) image from a <strong>docker compose file</strong> in my own VS 2017 project. What I try to accomplish here is to initialize the database from a script. I tried using the "command" switch in the <strong>docker.compose.yml</strong> but without much success...</p>
  
  <p>Here's the docker compose file :</p>
  
  <pre><code>  myscustomservice:
      image: myscustomservice
      build:
        context: .\myscustomservice
        dockerfile: Dockerfile
  
    db:
      image: microsoft/mssql-server-windows-express
      volumes:
         - ".\\data:C:\\data"
      #command: --init-file C:\\data\\CreateLocalDB.sql
      #command: "sqlcmd -U sa -P sUper45!pas5word -i C:\\data\\CreateLocalDB.sql"
      restart: always
      ports: 
        - "1533:1433"
      environment:
        - "sa_password=sUper45!pas5word"
        - "ACCEPT_EULA=Y"
  
  volumes:
    db-data: 
  </code></pre>
  
  <p>Note that I have tried the 2 command lines that are commented. First one fails saying it doesn't find the file and second one just replace the normal command line by that one, so the container doesn't start (or doesn't stay up). </p>
  
  <p>On my local drive, I have a C:\myscustomservice\data drive with the file CreateLocalDB.sql in it. It is mounted on the container in the C:\data folder (I see it when I run powershell inside the container).</p>
  
  <p>The sql file looks like this :</p>
  
  <pre><code>USE MASTER
  
  CREATE DATABASE [customDB_test]
   CONTAINMENT = NONE
   ON  PRIMARY 
  ( NAME = N'customDB_test', FILENAME = N'C:\data\customDB_test.mdf' , SIZE = 1594752KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
   LOG ON 
  ( NAME = N'customDB_test_log', FILENAME = N'C:\data\customDB_test.ldf' , SIZE = 3584KB , MAXSIZE = 2048GB , FILEGROWTH = 10240KB )
  GO  
  </code></pre>
  
  <p>Does anyone have an idea how could I do this ? All examples on the net are from linux containers, and this image is from Windows Server container.</p>