Routing to Different SQL Server Instances Running through Docker on Default Port Routing to Different SQL Server Instances Running through Docker on Default Port docker docker

Routing to Different SQL Server Instances Running through Docker on Default Port


As mentionned earlier traefik is not the right solution since it's a HTTP only LoadBalancer.

I can think right now in 3 different ways to achieve what you want to do :

  • Use a TCP Load Balancer like HAproxy
  • Setup you server in Docker Swarm Mode (https://docs.docker.com/engine/swarm/), that will allow to bind the same port with a transparent routing between them
  • Use a service discovery service like consul and SRV records that can abstracts ports number (this might be overkill for your needs and complex to setup)


you can't use traefik, because it's a HTTP reverse proxy.

You're sql server listen and communicate via TCP.

I don't understand what's you're final goal.Why are you using 2 differents sql-server ?

It depends on what's you want but you may have two solutions:

  • Can you use a simpler solution ? different databases, roles and permissions for separation.
  • You can search into the documentation of SQL Server Always On, but it doesn't seems easy to route queries to specific sever.


There is no "virtual" access to databases like for HTTP servers. So - no additional hostnames pointing to same IP can help you.

If you insist on port 1433 for all of your instances, then I see no way for you except to use two different external IPs.

If you were on a Linux box you may try some iptables magic, but it not elegant and would allow access to only one of your instances at any single moment. Windows may have iptables equivalent (I never heard of it) but still only-one-at-a-time you cannot escape.

My advice - use more than one port to expose your servers.