Search code examples
sql-serverdocker

What are the advantages of running SQL Server in a Docker container?


I need to run an SQL Server (Express) instance on my dev machine to work with a web application.

I recently started working with Docker and I'm wondering if there is some advantage using the Microsoft SQLServer Docker image instead of simply installing SQL Server on my machine.

I'm working on a Win10 machine.


Solution

  • Fast installation

    Better to say no installation needed if you already have Docker installed. Just provide 3 env vars (Server type, password and accept EULA) to docker run and you're ready.

    Automatic installation/deploy

    You can start SQL with just a few commands, no need for user interactive process. Very useful for CI/CD pipeline.

    Cloud-ready

    Want to run you solution on VPS? Or GCP/AKS/AWS? You are just one step away - with kubernetes your containers can be run anywhere.

    Cheap

    Windows-based virtual servers are more expensive than Linux. Testing your solution could be done on Linux runners and save you money.

    Testing against different servers/version

    Following @DanGuzman 's comment, you can test your solution with different versions of SQL server by just changing the tag of the image or SQL Server type in environment var.

    Isolation

    Easily create separate bridge networks with SQL Server, control access. Can start several instances on one PC at once easily by just separating networks by Docker means.

    Resetting

    Testing requires that you can reset all changes and start all tests from scratch (from same starting point). With containers and their volumes you achieve that with one command.

    Transparent configuration

    You provide Dockerfile and docker-compose.yml where all steps are explicitly written clear. No need to provide additional readme's on how to setup your server.

    Cross-platform

    Developers can use different operating systems when working on big projects (our case). Docker configuration will run on any without changes. Maybe your designers use MacOS and also want to run the solution locally? Easy with Docker.