Docker + mssql-server-linux: How to launch .sql file during build (from Dockerfile)

后端 未结 3 1726
长情又很酷
长情又很酷 2021-02-02 11:05

I am trying to create my own Docker image with MSSQL DB for development. It\'s based on microsoft/mssql-server-linux image. During the build I want to copy some

3条回答
  •  日久生厌
    2021-02-02 11:15

    I ended up using a slightly modified version of VDR's solution which waits for the sqlservr to start by checking the logs instead of sleeping 10 seconds:

    RUN ( /opt/mssql/bin/sqlservr --accept-eula & ) | grep -q "Service Broker manager has started" \
        && /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'P@ssw0rd' -i /opt/mssql-scripts/000_create_db.sql \
        && pkill sqlservr 
    

提交回复
热议问题