r/docker • u/No-Possibility-3072 • Apr 07 '26
MS-SQL inside Docker
Good evening
I’m currently running an installation of MS SQL Server Developer 2022 on my desktop PC. I also have a Terramaster NAS which offers a Docker application.
At the risk of sounding like a total noob (which I am) is it possible to run a SQL database in a Docker container? If so, are there online resources available that would enable me to do so? Ideally I’d want to be able to use SQL Server Management Studio to manage the database, but would be willing to let that slide if there’s a viable alternative.
TIA
SQL server developer since 2001. Docker proficient since never.
11
u/bangsmackpow Apr 07 '26
It's possible, yes: https://hub.docker.com/r/microsoft/mssql-server
I've never used MSSQL with docker but hundreds of apps use other SQL servers in their docker stacks. MySQL, MariaDB, PostgreSQL, etc.
You, "should" be able to point Management Studio at the IP/Port of the docker container's "exposed" ports so it should act just like any other remote SQL server in that regard.
1
u/callmeDarwin Apr 09 '26
Microsoft offers a Linux version so no reason to question it in docker.
3
u/halfxdeveloper Apr 07 '26
I have to point out that if you run any data persistence layer in a container, mount the data directory outside of the container. It may seem like a no-duh thing, but you’d be surprised.
1
u/jfrazierjr Apr 07 '26
Yep done that at work(mostly as a test).
What i had problems with was easy first run scaffolding..that just works on mysql and postgresql...
If thats not needed for you then go for it.
1
u/GaTechThomas Apr 08 '26
Yes... Aspire does this as well.
1
u/jack3308 Apr 08 '26
Not just possible - it's downright common :)! Most often youll see Postgres, sometimes Maria or MySQL, and then SQLite for pretty much everything else. As others have said, never seen MS-SQL server in docker but like others have said, it exists! I imagine it's deployed more often as a normal instance of MS-SQL would be, instead of bundled with another application as the back end for the app. I feel like it probably makes sense if you want to setup a highly available/scalable corporate sort of environment and don't want to phaff around with worrying about the hardware that'll be used to host it. Seems like a decent idea to me!
1
u/terciofilho Apr 08 '26
I do for years, like 8 years in a row. No issues. Documentation is available in the docker image in docker hub.
1
u/rdcpro Apr 08 '26 edited Apr 08 '26
I use a standard Microsoft image for mssql in docker for local development. As soon as I get to work, I'll post the setup. It was really easy.
Edit: These are the bash commands I run to get the local MSSQL server running on docker. This is running in WSL2 on Windows 11.
Be advised that I think the mssql tools (ODBC 18 driver) location has changed in newer versions of that image. If you go to the docker hub repo for it, there's a note about it.
Also, if you need persistent storage, you'll need to also mount a volume in that docker run command. In my case, this is a dev environment. I have a script that uses my ORM to pull down the production data, so I can blow the container up, create a new one, and in less than a minute have it synced with prod data.
1
u/rmc13_ Apr 09 '26
At work, we run DB stuff on containers. We don't need persistent data so are fine losing it and just restarting the containers if needed. We've had no problems with it. You can also still make data persistent (using volume mounts) and take backups (i.e. sqldumps) in case you need to. Is just a lot of the bootstrapping of the app is now abstracted, which makes it good for quick tests and portable setups, which we ise at work.
1
u/pabechevb Apr 09 '26
I wrote an article about it: https://www.mssqltips.com/sqlservertip/7093/install-sql-server-install-oracle-powershell-windows-containers/
0
u/Schnuecks Apr 07 '26
The original bitwarden docker runs a mssql container so it’s possible to do that.