Sql server docker examples

examples from sql server docker official image, bash exampless with 2017, 2019

Last update: 2020-11-23

Link to original resource:

https://hub.docker.com/_/microsoft-mssql-server

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=qwerty$123' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu 

Start a mssql-server instance using the CU8 release IMPORTANT NOTE: If you are using PowerShell on Windows to run these commands use double quotes instead of single quotes.

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-CU8-ubuntu

Start a mssql-server instance using the latest update for SQL Server 2017

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest

Start a mssql-server instance running as the SQL Express edition

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu 

Connect to Microsoft SQL Server You can connect to the SQL Server using the sqlcmd tool inside of the container by using the following command on the host:

docker exec -it <container_id|container_name> /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <your_password>

My docker sql server command, mount is only for restore database purpouses

2017

docker run --mount type=bind,source="C:\tmp",target=/tmp/  -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=qwerty$123' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu

2019

docker run --mount type=bind,source="C:\tmp",target=/tmp  -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=qwerty$123' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04