This container is based on the microsoft/mssql-server-linux container. Some modifications were made in order to allow for the container to attach to a remote database. These changes added two new environment variables to the docker run command for that container. See their description below. The additions include a patch to the embedded sqlservr.sh script and C program that handles starting the appropriate
Map a directory on the host machine to the remote filesystem, which contains the database and database log files (Keep them all in one directory). For this example, the directory 'eds1Share/linux-mssql' has been mapped on the host to the remote filesystem, which is the parent directory of the SQL Server files, to enable multiple databases to be on the remote filesystem so that multiple containers could be run on the same host, with different attached databases, without having to map multiple locations unnecessary.. Note: The "-v" mapping should point to the directory of the "data" and "log" directories created by SQL Sever on the remote filesystem for these databases and it is assumed that these files are all located in the same directory.
Start the container as follows: [No attached database]
Replace the ****** value with the actual password you have decided to use for this SQL Server instance.
--cpus can be set to your preference, but testing on an Ubuntu 16.10 Server host shows that the server preformed most efficiently with at least 3 CPU's, and that the performance gains after adding more CPU's showed a plateau..
-m can be set to your preference, however, performance testing on an Ubuntu 16.10 Server host shows that 4Gb appears to be sufficient for the typical csip queries. Memory sizes as little as 1Gb were also tested with success, albeit slightly slower response times. However, please note that Docker states that a minimum of 3.25Gb of RAM is required for this container.
Your host machine may use swap space, but no performance gains were observed for this container when swap was enabled on the host, and some performance degradation can be observed depending on where and how swap is enabled on the host machine.
This container stores its SQL Server System databases within its own filesystem in the container. Persistence of data is not necessary for these system databases past the current configuration additions already setup inside of this particular container image. However, they could grow in size, as the image is used and therefore the host should have space available for that storage.
This image has been tested with multiple copies running on the same host machine. Each one being attached to the exact same database file on the remote filesystem.
No conflicts have been observed with the remote database files or log files.
Performance of each instance appears to be comparable to that of a single instance indicating that scalability on the same host performs well.
If not using a load balancing and/or proxy server with the containers, be sure to alter the -p commandline option listed above to map any new instances to other ports on the host machine:
Exmaple: -p 1434:1433, or -p 1435:1433, etc.
Be sure to open the firewall on the additional ports for those instances as well:
After starting the image with docker run, you must subsequently attach the database to the running instance of mssql. To continue with our previous example, to attach a database:
% /opt/mssql-tools/bin/sqlcmd -S <IP address of mssql instance> -U sa -P <password> -d master -Q "CREATE DATABASE <database name> ON (FILENAME='c:\var\opt\mssql\shared_data\<database name>.mdf'), (FILENAME='c:\var\opt\mssql\shared_data\<database name>_log.ldf') FOR ATTACH;"
% /opt/mssql-tools/bin/sqlcmd -S <IP address of mssql instance>-U sa -P <password> -d master -Q "ALTER DATABASE <database name> SET READ_ONLY;"
This example assumes that the database name is used for the database mdf and log files. This many not always be the case. Check your actual names used in SSMS of the mssql instance that created the databases you wish to use.
There may be more than one log file for a database. If there are more than one, you may continue the command line above by as many ", (FILENAME=...)" constructs as are necessary to include all files needed.
Notice that the filenames used emulate the DOS filesystem even though they are on a Linux container. This is a requirement of mssql since it was written by Microsoft. It assumes your root directory is "C:" not "/" as would be the norm for Unix. Do not worry about this obvious error. The internal mechanisms in the container figure it out correctly.
This example assumes that you have sqlcmd installed on your host machine. If you do not have it, you may install it from Microsoft for Linux. It is known as mssql-tools. The Ubuntu method of installation is:
% sudo apt-get install mssql-tools