Connect to Sitecore databases running on containers

Pranay
Feb 21, 2022  ยท  755 views

Here is how we can connect and query Sitecore's SQL Server Databases running inside docker containers

If you are working on Sitecore development using Docker containers then you would someday definitely need to connect to SQL Server database and query the database tables. Since the SQL Server also running on Docker containers you cannot directly connect to them from SQL Server Management Studio (SSMS). Here are the steps you need to follow to connect to the Databases from SSMS.

SSMS to DB running on containers

1. Fetch container IP address

Get the IP address of the container on which the SQL Server is running on using the following command in Powershell.

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' your_mssql_container_id_here
	

2. Fetch database credentials

Go to the .env file which is used for the docker setup and fetch the SA password. The variable would be something like this SQL_SA_PASSWORD. Could be different if it is changed on your instance.

3. Connect using SSMS

Connect to the database using the SQL Server Management Studio with Server name : IP address of the container
Login: sa Password: Password from .env file

SSMS login to docker

This should connect to the SQL Server and you should see the databases and tables inside them. Hope this helps.

AUTHOR

Pranay

A Software Engineer by profession, a part time blogger and an enthusiast programmer. You can find more about me here.


Post a comment




Thank you! You are now subscribed.

Sign up for our newsletter

Subscribe to receive updates on our latest posts.

Thank you! You are now subscribed.