SQL Server on docker with new variables

SQL Server on Docker with new Environment Variables

As of CTP 2.1 for SQL Server 2017 a set of new environment variables are available. These variables allow us to configure each SQL Server container as we spin them up. The first version of SQL Server on Linux came with:


These had to be set for the container to start. The SA_PASSWORD has be a complex password or the container will not start. CTP 2.1 introduced:


Test run

First, I need to pull the latest version of the SQL Server for Linux image.

Docker pull sql server linux
I already had the CTP 2.0 image so docker only needs to download the differences.

My run command sets some data directories and a non default port of 6666. I can still use the -p variable to set port mappings for this container. So I will use port 5555 to connect, which will map to the port 6666 that SQL Server is listening on.

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P455word1' -e MSSQL_BACKUP_DIR=/etc/ -e MSSQL_DATA_DIR=/etc/ -e MSSQL_TCP_PORT=6666 -p 5555:6666 --rm --name mssql1 -d microsoft/mssql-server-linux

Running docker ps shows that my container is running with the ports I specified.

SQL Server on docker ps

I can check the logs of my container with docker logs mssql1 to see the port it’s listening on.

SQL Server on docker logs

Lastly I’ll connect with SSMS to check the new default file and backup locations.

SQL Server on docker backup settings
If not specified the directory would be /var/opt/mssql/data

This is a very nice addition when running SQL Server on docker, but I’d like to see more. It would be nice to be able to configure Max Memory, TempDB files, MAXDOP, etc. Fingers crossed for the RTM!



About the author

James Anderson

I'm a freelance SQL Server DBA in Southampton, UK. Performance tuning code and improving development processes are what I love to do for work. Outside of work, I live to travel to as many places as possible with my wife Sarah.

5 thoughts on “SQL Server on Docker with new Environment Variables”

  1. It sounds like SQL 2017 is the first version to support docker/containers, is that correct? Or can you do any of this with say SQL 2016 SP1?

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up

James Anderson SQL Server DBA

Hi, I'm James Anderson. When I'm not blogging about SQL Server, I do this.

The SQL People

DBA Stackexchange Profile