Skip to content

arehmandev/mssql-linkedserver-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mssql-nginx

Minimal setup to run two SQL Server containers and an Nginx TCP proxy for testing linked-server behavior.

Prerequisites

  • Docker Desktop (macOS/Linux).
  • On Apple Silicon (M1/M2) optional: install Rosetta and enable Docker Desktop 'Use Rosetta for x86/amd64 emulation' if you plan to run amd64 images.
    • Install Rosetta: sudo softwareupdate --install-rosetta --agree-to-license

Quick start

./scripts/run_all.sh

The script uses the mssql-tools container (amd64) and includes --platform linux/amd64 where needed.

Ports (host -> container)

  • nginx proxy to mssql1: 1433 -> (proxied to mssql1)
  • nginx proxy to mssql2: 1434 -> (proxied to mssql2)
  • direct mssql1 host mapping: 14331 -> container 1433
  • direct mssql2 host mapping: 14332 -> container 1433

Manual commands

  • Run a single SQL file against mssql1 via the proxy using the helper container (Apple Silicon: include --platform):

    docker run --platform linux/amd64 --rm -it -v "$(pwd)/sql:/work" mcr.microsoft.com/mssql-tools:latest
    /opt/mssql-tools/bin/sqlcmd -S host.docker.internal,1433 -U sa -P 'YourStrong!Passw0rd' -i /work/test_linked_server.sql

  • Or connect directly to mssql2 to list databases:

    docker run --platform linux/amd64 --rm -it mcr.microsoft.com/mssql-tools:latest
    /opt/mssql-tools/bin/sqlcmd -S host.docker.internal,14332 -U sa -P 'YourStrong!Passw0rd' -Q "SELECT name FROM sys.databases;"

Notes

  • The project includes:
    • docker-compose.yml - services and ports
    • nginx/nginx.conf - TCP stream proxy config
    • sql/ - helper SQL scripts used by scripts/run_all.sh
    • scripts/run_all.sh - orchestrates init, startup, and SQL tests
  • If you need full SQL Server parity (linked servers), this compose uses full SQL Server images with platform: linux/amd64 (emulated on Apple Silicon). If you prefer a native ARM image, use Azure SQL Edge but be aware it does not support sp_addlinkedserver.

Troubleshooting

  • Check logs: docker compose logs -f mssql1 mssql2 nginx
  • Check container status: docker compose ps
  • If services fail to start due to permissions, run the init job manually as shown above.

About

Example of MSSQL linkedserver proxy via nginx

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors