Run MSSQL in Docker on Linux

Published: January 11, 2026

← Back to Home

Running Microsoft SQL Server in a Docker container on Linux is surprisingly straightforward and opens up some interesting possibilities. Whether you’re setting up a development environment, testing database migrations, or even running SQL Server on a Raspberry Pi (because you can!), Docker makes it easy to get up and running quickly without a full SQL Server installation.

This guide covers everything from installing Docker on Linux to running SQL Server 2022 in a container. I’ll also show you how to run Azure SQL Edge on ARM devices like Raspberry Pi. While SQLite is usually my go-to for embedded devices, running MSSQL on a Pi with Docker is totally doable if you have the RAM for it.

Run all these commands on your Linux machine:

Install Docker

First, we need to get Docker installed. Docker provides an official convenience script that handles the installation for you — it detects your OS, adds the necessary repositories, and installs Docker Engine:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

The first command downloads the Docker installation script to a file called get-docker.sh. The second command runs that script with sudo privileges. The script adds Docker’s official repository to your package manager and installs the latest version of Docker Engine.

Add your user to the Docker group:

By default, Docker requires root privileges to run. To avoid typing sudo before every Docker command, add your user account to the docker group:

sudo usermod -aG docker $USER

This command adds your current user ($USER) to the docker group. After running this command, you’ll need to log out and log back in (or reboot) for the group membership change to take effect. Once you do, you’ll be able to run Docker commands without sudo.

Verify Docker is running:

After logging back in, confirm that Docker is installed and your user has the right permissions:

docker ps

If Docker is running correctly and your user has proper permissions, you’ll see a list of running containers (which will be empty if you haven’t started any containers yet). If you get a permission error, make sure you logged out and back in after adding yourself to the docker group.

Run SQL Server 2022 in Docker

Now that Docker is set up, running SQL Server is just one command. This command starts SQL Server 2022 in a container with all the necessary configuration:

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong@Passw0rd" -p 1433:1433 --name sql1 --hostname sql1 --restart always -d mcr.microsoft.com/mssql/server:2022-latest

Let’s break down what this command does:

After running this command, Docker will download the SQL Server image (if you don’t have it already) and start the container. This may take a minute or two depending on your internet connection and system.

Running SQL Server on Raspberry Pi (ARM Devices)

If you want to run SQL Server on a Raspberry Pi or other ARM-based device, you’ll need to use Azure SQL Edge instead of the standard SQL Server image. Azure SQL Edge is Microsoft’s lightweight database engine designed for ARM architectures and IoT devices.

Note: You’ll need at least 4GB of RAM, though 8GB is recommended. I ran this successfully on a Raspberry Pi 4 with 8GB of RAM.

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong@Passw0rd" -p 1433:1433 --name sql3 --hostname sql3 --restart always -d mcr.microsoft.com/azure-sql-edge

This command is nearly identical to the SQL Server 2022 command above, but uses the azure-sql-edge image instead. Azure SQL Edge provides most of SQL Server’s core functionality in a smaller package that runs on ARM processors.

A practical note: While running SQL Server on a Raspberry Pi is totally possible and makes for a fun learning experience, SQLite is usually a better choice for embedded devices and small-scale applications. I typically use SQLite on Raspberry Pi projects — running MSSQL in Docker on a Pi was more of a “can I do this?” experiment. But if you need SQL Server’s specific features or compatibility, now you know it’s possible!

Verify the Container is Running

Check that your SQL Server container started successfully:

docker ps

You should see your container (either sql1 or sql3) listed with a status of “Up” and port 1433 exposed. If the container isn’t running, check the logs for errors:

docker logs sql1

Replace sql1 with your container name if you used a different one.

Default Credentials

Your SQL Server instance is now running and accessible on port 1433. Use these default credentials to connect:

Username:

SA

Password:

YourStrong@Passw0rd

IMPORTANT: This default password is just for demonstration purposes. In any real environment — whether it’s development, testing, or production — you must change this to a strong, unique password. SQL Server password requirements include:

Never expose port 1433 directly to the internet without proper security measures like firewalls, VPNs, or Tailscale networks. For development environments, consider keeping SQL Server accessible only on your local network or through secure tunneling solutions.

Connecting to Your SQL Server Instance

You can now connect to your SQL Server instance using any SQL Server client tool:

Connection string format:

Server=<your-linux-machine-ip>,1433;Database=master;User Id=SA;Password=YourStrong@Passw0rd;TrustServerCertificate=True;

Replace <your-linux-machine-ip> with your Linux machine’s IP address. If you’re connecting from the same machine, you can use localhost.

Managing Your SQL Server Container

A few useful Docker commands for managing your SQL Server container:

Stop the container:

docker stop sql1

Start the container:

docker start sql1

Remove the container:

docker rm sql1

Note that removing the container will delete all your databases and data unless you’ve configured persistent volumes. For production use, you should set up Docker volumes to persist your data outside the container.

Next Steps

With SQL Server running in Docker, you can:

Running SQL Server in Docker on Linux gives you flexibility and portability. You can spin up instances quickly, tear them down just as fast, and run multiple versions side-by-side if needed. Whether you’re on a powerful server or experimenting on a Raspberry Pi, Docker makes SQL Server accessible on Linux in a way that wasn’t possible just a few years ago.

Microsoft SQL Server Docker Documentation: https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker

Azure SQL Edge Documentation: https://learn.microsoft.com/en-us/azure/azure-sql-edge/disconnected-deployment

Keep building!