Thank you for being a valued client of CM First Group. If you have any technical issues or concerns, please open a ticket on, email CM First technical support at or call us on our 24/7 customer hotline at +1 (512) 623-7586.


How to Create and Run MS SQL Server Docker Container


  • MS SQL Docker image

    How to download MS SQL Docker image.

    docker pull Microsoft/mssql-server-linux 

Docker Configuration

  1. To run Linux SQL Server Container properly, the server needs to have at least 3.25Gb 
  2. shows the command to run the SQL Server image. You can use PowerShell to run the container. The password requirement for the system administrator is at least 8 characters including uppercase, lowercase letters, base-10 digits and/or non-alphanumeric symbols. 

    docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-Linux

  3. If you need a GUI Interfact to connect to your SQL Server, you can install SQL Server Management Studio ( After installing you can connect to your SQL Server like the following. The server name should be set to 127.0.01,1500 (use comma instead of a colon for the port). The username is SA. The password should be from the environment variable in the Docker run command. 

How to Create a MS SQL Docker with a BAK File Restored

  1. Create a dockerfile like follows

    FROM microsoft/mssql-server-linux 
    RUN apt-get update 
    RUN apt-get install -y wget curl apt-transport-https 
    RUN curl | apt-key add - 
    RUN wget -O /etc/apt/sources.list.d/msprod.list 
    RUN apt-get update  
    RUN echo yes | apt-get install -y msodbcsql 
    RUN echo yes | apt-get install -y mssql-tools 
    RUN locale-gen en_US en_US.UTF-8 
    RUN dpkg-reconfigure -f noninteractive locales  
    COPY yourbakfile.bak /dbdump/ 
    CMD (/opt/mssql/bin/ & sleep 60 && /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'yourStrong(!)Password' -Q "RESTORE DATABASE YOURDATABASENAME FROM DISK = '/dbdump/yourbakfile.bak' WITH MOVE 'YOURDATABASENAME' TO 'C:\var\opt\mssql\data\yourdatabasename.mdf', MOVE 'YOURDATABASENAME_log' TO 'C:\var\opt\mssql\data\yourdatabasename.ldf'" && tail -f /dev/null) 

  2. Build the docker file. 

    docker build --tag mysqlserver .

  3. How to run docker file.

    docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p yourportnumber:1433 -v C:/temp:/dbdump -d mysqlserver 


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk