Skip to main content

Docker Compose file for running a SQL Server (MSSQL) instance.

version: "3.9"

#
# SQL Server Docker Compose File
# Source: https://jonlabelle.com/snippets/view/yaml/sql-server-docker-compose-file

volumes:
  mssql:

services:
  mssql:
    image: mcr.microsoft.com/mssql/server:latest
    container_name: mssql
    # See SQL Server Linux Environment Variables: https://docs.microsoft.com/sql/linux/sql-server-linux-configure-environment-variables
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: "example_123"
      MSSQL_MEMORY_LIMIT_MB: "1024"
      TZ: "America/Chicago"
      MSSQL_PID: "Developer"
    hostname: mssql
    ports:
      - "1433:1433"
    restart: always
    healthcheck:
      test: [ "CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P example_123 -Q 'SELECT 1' || exit 1" ]
      interval: 10s
      retries: 10
      start_period: 10s
      timeout: 3s

    volumes:
      - mssql:/var/opt/mssql