microsoft / mssql-docker

Official Microsoft repository for SQL Server in Docker resources
MIT License
1.71k stars 755 forks source link

db initialization stops working #537

Closed lkurzyniec closed 4 years ago

lkurzyniec commented 4 years ago

As I wrote here https://github.com/microsoft/mssql-docker/issues/519 and then here https://github.com/microsoft/mssql-docker/issues/2 (last comment), I achieved to initialize db with my custom SQL script. Lately, it stops working. I receive such logs from docker-compose:

mssql                  | SQL Server 2019 will run as non-root by default.
mssql                  | This container is running as user root.
mssql                  | Your master database file is owned by UNKNOWN.
mssql                  | To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
mssql                  | ./entrypoint.sh: ./entrypoint.sh: is a directory
mssql exited with code 126

My docker-compose file

version: "3.6"

services:
  mssql:
    image: mcr.microsoft.com/mssql/server:2017-latest
    container_name: mssql
    command: /bin/bash ./entrypoint.sh
    ports:
      - 1433:1433
    environment:
      - ACCEPT_EULA=Y
      - MSSQL_PID=Express
      - SA_PASSWORD=SomeStrongPwd123
    volumes:
      - dbdata:/var/opt/mssql/data
      - ./db/mssql/docker-entrypoint.sh:/entrypoint.sh
      - ./db/mssql/docker-db-init.sh:/db-init.sh
      - ./db/mssql/mssql-cars.sql:/db-init.sql

  netcore-boilerplate:
    image: netcore-boilerplate:local
    container_name: netcore-boilerplate
    build:
      context: .
    ports:
      - 5000:80
    depends_on:
      - mssql

volumes:
  dbdata:

And entrypoint.sh file

#start SQL Server, start the script to create/setup the DB
 /db-init.sh & /opt/mssql/bin/sqlservr
lkurzyniec commented 4 years ago

Problem solved. There was a problem with volumes - my firewall blocked Shared Drives (problem described here https://github.com/docker/for-win/issues/1501). Fixed by this https://stackoverflow.com/questions/42203488/settings-to-windows-firewall-to-allow-docker-for-windows-to-share-drive/