Skip to content

Instantly share code, notes, and snippets.

@oskaremil
Created November 21, 2023 11:23
Show Gist options
  • Save oskaremil/9c817b001d81b6a2ccaf263fcf7f45ef to your computer and use it in GitHub Desktop.
Save oskaremil/9c817b001d81b6a2ccaf263fcf7f45ef to your computer and use it in GitHub Desktop.
Docker MSSQL
#!/bin/bash
docker exec sql-server /opt/mssql-tools/bin/sqlcmd -U sa -P *** -Q "CREATE DATABASE TestDatabase"
docker exec sql-server /opt/mssql-tools/bin/sqlcmd -U sa -P *** -Q "CREATE LOGIN testuser WITH PASSWORD = '***'"
docker exec sql-server /opt/mssql-tools/bin/sqlcmd -U sa -P *** -d TestDatabase -Q "CREATE USER testuser FOR LOGIN testuser"
docker exec sql-server /opt/mssql-tools/bin/sqlcmd -U sa -P *** -d TestDatabase -Q "ALTER ROLE db_owner ADD MEMBER testuser"
#!/bin/bash
docker volume create sql-server-system
docker volume create sql-server-user
#!/bin/bash
docker run \
--volume sql-server-system:/var/opt/mssql \
--volume sql-server-user:/var/opt/sqlserver \
-e "ACCEPT_EULA=Y" -e "SA_PASSWORD=***" \
-e "MSSQL_RPC_PORT=135" -e "MSSQL_DTC_TCP_PORT=51000" \
-p 1433:1433 -p 135:135 -p 51000:51000 \
--name sql-server \
--detach --rm mcr.microsoft.com/mssql/server:2022-latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment