mcr.microsoft.com/mssql/server:2017-GA-ubuntu
). To see all available images, see the mssql-server Docker hub page.sudo
is used. On MacOS, sudo
might not be required. On Linux, if you do not want to use sudo
to run Docker, you can configure a docker group and add users to that group. For more information, see Post-installation steps for Linux.docker run
example:Parameter | Description |
---|---|
-e 'ACCEPT_EULA=Y' | Set the ACCEPT_EULA variable to any value to confirm your acceptance of the End-User Licensing Agreement. Required setting for the SQL Server image. |
-e 'SA_PASSWORD=<YourStrong!Passw0rd>' | Specify your own strong password that is at least 8 characters and meets the SQL Server password requirements. Required setting for the SQL Server image. |
-p 1433:1433 | Map a TCP port on the host environment (first value) with a TCP port in the container (second value). In this example, SQL Server is listening on TCP 1433 in the container and this is exposed to the port, 1433, on the host. |
--name sql1 | Specify a custom name for the container rather than a randomly generated one. If you run more than one container, you cannot reuse this same name. |
-d mcr.microsoft.com/mssql/server:2017-latest | The SQL Server 2017 Linux container image. |
docker ps
command.-h
(host name) parameter is also useful, but it is not used in this tutorial for simplicity. This changes the internal name of the container to a custom value. This is the name you'll see returned in the following Transact-SQL query:-h
and --name
to the same value is a good way to easily identify the target container.sudo
is used. On MacOS, sudo
might not be required. On Linux, if you do not want to use sudo
to run Docker, you can configure a docker group and add users to that group. For more information, see Post-installation steps for Linux.docker run
example:Parameter | Description |
---|---|
-e 'ACCEPT_EULA=Y' | Set the ACCEPT_EULA variable to any value to confirm your acceptance of the End-User Licensing Agreement. Required setting for the SQL Server image. |
-e 'SA_PASSWORD=<YourStrong!Passw0rd>' | Specify your own strong password that is at least 8 characters and meets the SQL Server password requirements. Required setting for the SQL Server image. |
-p 1433:1433 | Map a TCP port on the host environment (first value) with a TCP port in the container (second value). In this example, SQL Server is listening on TCP 1433 in the container and this is exposed to the port, 1433, on the host. |
--name sql1 | Specify a custom name for the container rather than a randomly generated one. If you run more than one container, you cannot reuse this same name. |
mcr.microsoft.com/mssql/server:2019-CTP3.2-ubuntu | The SQL Server 2019 CTP3.2 Linux container image. |
docker ps
command.-h
(host name) parameter is also useful, but it is not used in this tutorial for simplicity. This changes the internal name of the container to a custom value. This is the name you'll see returned in the following Transact-SQL query:-h
and --name
to the same value is a good way to easily identify the target container.SA_PASSWORD
environment variable you specified is discoverable by running echo $SA_PASSWORD
in the container. For security purposes, change your SA password.docker exec
to run sqlcmd to change the password using Transact-SQL. In the following example, replace the old password, <YourStrong!Passw0rd>
, and the new password, <YourNewStrong!Passw0rd>
, with your own password values.docker exec -it
command to start an interactive bash shell inside your running container. In the following example sql1
is name specified by the --name
parameter when you created the container.1>
.TestDB
.GO
on a new line to execute the previous commands:Inventory
, and insert two new rows.TestDB
database:Inventory
:GO
to execute the previous commands:Inventory
table.Inventory
table where the quantity is greater than 152:QUIT
:exit
. Your container continues to run after you exit the interactive bash shell.QUIT
.