Run the SQL Server 2017 Docker image on Linux, Mac, or Windows

This topic explains how to pull and run the mssql-server Docker image. This image consists of SQL Server running on Linux and can be used with the Docker Engine 1.8+ on Linux or on Docker for Mac/Windows. We are currently tracking all issues with the Docker image in our mssql-docker GitHub repository.

Note

This image is running SQL Server on an Ubuntu Linux base image. To run the SQL Server on Windows Containers Docker image, check out the mssql-server-windows Docker Hub page.

Requirements for Docker

  • Docker Engine 1.8+ on any supported Linux distribution or Docker for Mac/Windows.
  • Minimum of 4 GB of disk space
  • Minimum of 4 GB of RAM
Important

The default on Docker for Mac and Docker for Windows is 2 GB for the Moby VM, so you will need to change it to 4 GB. The following sections explain how.

Docker for Mac

  1. Click on the Docker logo on the top status bar.
  2. Select Preferences.
  3. Move the memory indicator to 4GB or more.
  4. Click the restart button at the button of the screen.

Docker for Windows:

  1. Right-click on the Docker icon from the task bar.
  2. Click Settings under that menu.
  3. Click on the Advanced Tab.
  4. Move the memory indicator to 4GB or more.
  5. Click the Apply button.

Pull and run the Docker image

  1. Pull the Docker image from Docker Hub.

     sudo docker pull microsoft/mssql-server-linux
    
    Tip

    If you using Docker for Windows, remove the word sudo from the command-line in this step and step three.

  2. To run the Docker image, you can use the following commands:

     docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -d microsoft/mssql-server-linux
    
    Note

    The ACCEPT_EULA and SA_PASSWORD environment variables are required to run the image. Setting the ACCEPT_EULA variable to any value confirms your acceptance of the End-User Licensing Agreement.

  3. To persist the data generated from your Docker container, you must map volume to the host machine. To do that, use the run command with the -v <host directory>:/var/opt/mssql flag. This will allow the data to be restored between container executions.

     sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -v <host directory>:/var/opt/mssql -d microsoft/mssql-server-linux
    
    Important

    Volume mapping for Docker-machine on Mac with the SQL Server on Linux image is not supported at this time.

Upgrading the Docker image

Upgrading the Docker image will require just pulling the latest version from the registry. In order to do so, you just need to execute the pull command:

    sudo docker pull microsoft/mssql-server-linux:latest

You can now create new containers that will have the latest version of SQL Server in Linux on Docker.

SQL Server command-line tools

Starting with SQL Server 2017 CTP 2.0, the SQL Server command-line tools are included in the Docker image. If you attach to the image with an interactive command-prompt, you can run the tools locally.

Alternatively, you can connect to the SQL Server instance on your Docker machine from any external Windows or Linux tool that supports SQL connections, such as SQL Server Management Studio (SSMS) on Windows.

Next steps

After installing SQL Server on Linux, next see how to connect to the server and run basic Transact-SQL queries. Also, check out the mssql-docker GitHub repository for resources and feedback.