Running MSSQL with Docker Compose
This guide will walk you through setting up and running a Microsoft SQL Server instance using Docker Compose.
๐ฆ Prerequisites
Before you begin, make sure you have:
Docker Desktop installed and running
Your project already containing a docker-compose.yaml file
๐ Step 1: Open Your Project
Open your project in your preferred code editor (e.g. Visual Studio Code).
Locate the docker-compose.yml file in the root directory.
โถ๏ธ Step 2: Start the Containers
Open a terminal inside your project folder
Run:
Wait until Docker finishes pulling the image and starts the container
๐ Step 3: Verify Container is Running
To confirm everything is working:
You should see your MSSQL container listed with status Up.
Also copy CONTAINER_ID.
๐ฆ Step 4: Transfer .bak File into the Container
First, create a backup directory inside the running container:
Then copy your .bak file from the host machine into the container:
๐ก Tip: You can get the container ID using
docker ps
๐งช Step 5: Connect to the Database
You can connect using:
- Azure Data Studio
- SQL Server Management Studio
- Or any SQL client
Use these connection details:
- Server:
localhost - Port:
1433 - User:
sa - Password: (the one defined in your compose file)
SQL Server Management Studio Connection String:
๐ ๏ธ Step 6: Restore the Database
-
Open SQL Server Management Studio (SSMS)
-
Right-click on Databases
-
Select Restore Database...
-
Choose:
-
Source โ Device
-
Click
...and add your.bakfile from:
-
-
Confirm and start the restore process
โ ๏ธ If the backup does not appear, ensure the path is correctly set and the container has access to the file.
โ You're Done
You now have a running MSSQL instance inside Docker, ready for development and testing.