I have a linux docker container built on microsoft/mssql-server-linux/ image. The container doesn't have anything at this moment, I am trying to connect to remote MSSQL db hosted on windows server somewhere. I am not sure exactly how can I do that.
The documentation for microsoft/mssql-server-linux/ doesn't provide much of details. Any help would be appreciated.
Updated: I have got container working now. But, the container gets exited with code 0 if I try to create and seed db through bash script.
Here is docker file & docker-compose files
version: '2'
services:
db:
build: .
ports:
- "1433:1433"
environment:
ACCEPT_EULA: Y
SA_PASSWORD: Password
PATH: /opt/mssql-tools/bin:/opt/mssql/bin:$PATH
container_name: db
FROM microsoft/mssql-server-linux:latest
EXPOSE 1433
RUN echo $PATH
RUN mkdir -p /usr/src/app
COPY ./db/* /usr/src/app/
WORKDIR /usr/src/app
RUN ls
RUN chmod +x /usr/src/app/dbInit.sh
RUN chmod +x /usr/src/app/dbSeed.sh
CMD /bin/bash ./entrypoint.sh
Here is my entrypoint.sh:
/opt/mssql/bin/sqlservr & /usr/src/app/dbInit.sh
dbInit.sh contains SQLscripts to create db, some tables and seed them. something like this.
sqlcmd -S localhost -U SA -P password -d master -Q "CREATE DATABASE dbo"
The docker-compose up --build successfully creates db, tables and seeds them. But the container is exited with code 0. Seems like SQL Server it self is closed.