Running Microsoft SQL Server with Docker — A Game-Changer for Developers
Summary
Running SQL Server in Docker is a lifesaver for developers — no heavy installs, instant setup, and consistent environments! ⚙️ Just one docker-compose up -d spins up SQL Server 2022 ready to go. 🧠 Connect via SSMS using localhost,1433 and start building immediately. 💡 Fast, portable, and perfect for testing, CI/CD, or local dev workspaces.
Have you ever wanted to spin up a SQL Server environment without installing gigabytes of software? Docker makes it possible — cleanly, quickly, and consistently.
🧩 1️⃣ Why use SQL Server in Docker?
Running SQL Server in a container means:
No messy installs — just pull and run.
Instant reproducibility across machines.
Perfect for testing, CI/CD, and local dev.
Example:
Your dev team can run identical SQL Server 2022 instances on Windows, Mac, or Linux with a single command — eliminating “it works on my machine” issues.
⚙️ 2️⃣ How to run SQL Server in Docker
Create a folder and a docker-compose.yml file like this:
version: '3.8'
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: sqlserver
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "YourStrong!Passw0rd"
ports:
- "1433:1433"
volumes:
- sqlserverdata:/var/opt/mssql
volumes:
sqlserverdata:Then run:
docker-compose up -d✅ Example:
This spins up SQL Server 2022 locally on port 1433 with a persistent volume sqlserverdata.
💻 3️⃣ Connect using SQL Server Management Studio (SSMS)
Once it’s running:
Server name:
localhost,1433Login:
saPassword:
YourStrong!Passw0rd
Example:
Open SSMS → Connect → Enter the above credentials → You’re inside a fully functional SQL Server instance!
🧠 4️⃣ Example workflow
Let’s say you’re testing a new data model.
Spin up this container in seconds.
Run your migration scripts or seed data.
Stop it when done — your data persists in the named volume.
Need a clean slate?
docker-compose down -vremoves everything.
💡 Bonus Tips
Use strong passwords (
MSSQL_SA_PASSWORD).Tag your images (e.g.,
2022-latest) for version control.Mount host volumes for backups if needed.
Ideal for devs, testers, and educators alike.
🧭 Final Thought
Docker + SQL Server = flexibility + speed + consistency.
Big thanks to Vijayasimha BR for the clean walkthrough — this setup has become a staple in my dev toolkit.
Have you tried running databases in Docker? What’s your experience been like?