Installing SQL Server Express On Linux

Table of Contents

1. Synopsis

This document describes the installation procedure for SQL Server Express on Linux using Docker Container.

This free version will allow for DB sizes up to 10GB.

2. Install

  1. Create a docker compose file named compose.yml with the following contents:

    version: '3.7'
    services:
    
      # Define MSSQL
      mssql:
        container_name: MSSQL-DB
        image: mcr.microsoft.com/mssql/server:2019-latest
        environment:
          - TZ=America/New_York
          - PUID=0
          - PGID=0
          - MSSQL_PID=Express
          - ACCEPT_EULA=Y
          - MSSQL_SA_PASSWORD=${MSSQL_SA_PASSWORD}
        ports:
          - 1285:1433 #External port is 1285
        volumes:
          # Before starting this container
          # You need to create this directory manually and then
          # chmod 777
          - ./MSSQL-data:/var/opt/mssql
        restart: always
  2. Create an .env file containing the sa password:

    echo MSSQL_SA_PASSWORD=The-SA-Pass0rd > .env
  3. Create a data directory e.g., MSSQL-data

    1. Make the data directory

      mkdir MSSQL-data
    2. Change permissions

      chmod 777 MSSQL-data
  4. Start the container

    sudo docker-compose up -d

3. Connect

  1. Connect via Microsoft SQL Server Management Studio.

    DB Connection