Microsoft SQL Server in Docker
Running MS SQL Server in a docker container.
Note: MS SQL 2019 and later run non-root so the change-vol-ownership service is required to correct permissions on the bind mounted volumes.
Filename: docker-compose.yaml
# Filename: /srv/mssql.example.com/docker-compose.yaml
# Run MS SQL Server in a docker container
name: mssql-example-com
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
container_name: mssql.example.com
environment:
- ACCEPT_EULA=Y
- MSSQL_SA_PASSWORD=YourStrong@Passw0rd
- MSSQL_PID=Developer
ports:
- "1433:1433"
volumes:
- ./data:/var/opt/mssql
depends_on:
change-vol-ownership:
condition: service_completed_successfully
# Recent SQL Server uses non-root containers, fix volume permissions
change-vol-ownership:
image: mcr.microsoft.com/mssql/server:2019-latest
user: root
restart: no
volumes:
- ./data:/var/opt/mssql
command: ["chown", "mssql:", "/var/opt/mssql"]