Connecting to Windocks database containers

Windocks containers are isolated database instances (SQL Server, PostgreSQL, MySQL) on Windows running on unique ports. Deveopers and testers can connect to these containers using the IP address of the Windocks server combined with the port number in the connection string of their application or in the UI tool they use. Common issues and their solutions are as follows:

  • In case the application connection string has to be constant use docker create -p fixedportnumber yourimagename or docker run -p fixedportnumber -d yourimagename. Or put in the port number in the web application UI for a fixed port number. The REST API also supports specifying a fixed port number. Each developer can be assigned a few ports to use and they can use their assigned ports, so the connection strings do not need to change
  • Use port forwarding if you don't want to use a port to connect to database containers. In this case set up a pool of IP addresses and map them to the ports. Setup a pool of IP addresses associated with the Windocks server (one per developer or two per developer as many containers as each developer needs).

    netsh in ip add address "Local Area Connection" 192.168.1.111 255.0.0.0
    netsh in ip add address "Local Area Connection" 192.168.1.112 255.0.0.0
    etc

    Associate each IP address with a port:
    netsh interface portproxy add v4tov4 listenport=1433 listenaddress=192.168.1.101 connectport=10001 connectaddress=127.0.0.1
    netsh interface portproxy add v4tov4 listenport=1433 listenaddress=192.168.1.102 connectport=10002 connectaddress=127.0.0.1
    etc
  • If the instance names (INSTANCE10001, INSTANCE10002, etc) are not suitable, use SQL aliases to get better and more friendly names. Start SQL Configuration manager, select SQL Native Client Configuration and then Aliases and create a new Alias with a friendly name and the port No such as 10003 and server IP address of 127.0.0.1