Occasionally you may need to connect to the Sitecore SQL instance and inspect the databases when running in docker. This is relatively straightforward.
Using SQL Manager
1. Identify the IP address of your SQL Instance
PS> docker inspect container [options] <container id/name>
NOTE: IP address changes every time you run docker-compose up.
If you are not sure of the name of your container name or id you can use the following command to get list of running containers
PS> docker container ls
2. Grab the SQL password for the SA account.
In the root of the solution open the .env file and grab the SQL_SA_PASSWORD setting value.
3. Fire up SQL Management Studio and connect
Set the Server name = ip address from step 1
Login = sa
Password = password from step 2
Using MS Code
The mssql extension for Visual Studio Code is pretty awesome as it lets you connect to a SQL Server and query and view results with T-SQL.
To install the mssql extension
- select View > Command Palette, or press Ctrl+Shift+P, or press F1 to open the Command Palette.
- In the Command Palette, select Extensions: Install Extensions from the dropdown.
- In the Extensions pane, type mssql.
- Select the SQL Server (mssql) extension, and then select Install.
Connect to Sitecore SQL database Instance
- Click on the SQL Server icon or CTRL + Alt + D
- Click add connection and follow the prompts
- enter Server name/ip – use container ip located above using container inspect
- database name (optional) you could connect to a specific sitecore DB
- authentication Type: SQL Login
- SQL_SA_PASSWORD setting from .env file
- name your profile
One thought on “Querying your Sitecore SQL container”