Let’s Talk

We would love to hear from you. Want to know more about
our services or have any questions? Say Hi!

Securing Your Sitecore Development: Connecting Dockerized SQL to XM Cloud

February 1, 2024
Securing Your Sitecore Development: Connecting Dockerized SQL to XM Cloud
Mitesh Patel
Mitesh Patel
Technical Head

To establish secure connection of Docker SQL container with XM Cloud Solution you need to create separate network in docker.

A question might occur why we need separate network to establish a connection, when we can use the localhost as a server name and port number with it, Like

“Localhost,14330 “This is how we can define docker server into SSMS portal.

But when we down all the containers, then back them UP, we can see the changed IP Address of the SQL container, where connection breaks and we need to redeploy out connection string with the latest IP Address.


(SQL container connection issue)

We might face an issue shown above, the remote computer refused the network connection

To avoid such kind of errors, we need to use the IP Address and every container restart will change the IP Address of the SQL container.

Now to resolve the same we need to configure static IP to each container present under the XM Cloud docker compose file.

To define the Subnet in the docker environment we need to mention below subnet configuration in the “docker-compose.yml”

                        - subnet:  # set subnet here 

This will create the subnet in the docker environment, further we can now provide static ipv4 IP Address to each container.

We need to mention this in the services section, where all the container configuration will be there,

                            isolation: ${ISOLATION} 
                            image: ${SITECORE_NONPRODUCTION_DOCKER_REGISTRY}nonproduction/mssql-developer:2017-${EXTERNAL_IMAGE_TAG_SUFFIX} 
                            SA_PASSWORD: ${SQL_SA_PASSWORD} 
                            ACCEPT_EULA: "Y" 
                            - "14330:1433" 
                            ipv4_address:  # set static IP 

Where my-network will assign the mentioned IP Address to the created container.


Now with the static IP Address we can go ahead with the IP Address as the server’s name of the SQL and connection will not break.


(SSMS connection with IP Address)

To use the same in the visual studio (MCloud Solution) we add the connection string in the Web Config, like below.


(Connection string to connect SQL container with Solution file)

With using this connection with the DB name, User ID and Password the connection will be established with the docker SQL container and XM-Cloud Solution, which gives you full control over the local development with the use of SQL. Like Custom DB and other integrations.