Blog Post

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:

ACCEPT_EULA
SA_PASSWORD

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:

MSSQL_TCP_PORT
MSSQL_IP_ADDRESS
MSSQL_BACKUP_DIR
MSSQL_DATA_DIR
MSSQL_LOG_DIR
MSSQL_DUMP_DIR
MSSQL_ENABLE_HADR

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!

 

 

The post SQL Server on Docker with new Environment Variables appeared first on The Database Avenger.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating