Deploy Microsoft SQL Server 2022
Pinned SQL Server 2022 CU Developer, volume, TCP 1433, generated SA secret.
MicrosoftSQL
Just deployed
/var/opt/mssql
Deploy and Host Microsoft SQL Server 2022 on Railway
Pinned SQL Server 2022 CU26 Developer edition. Persistent data at /var/opt/mssql, public TCP 1433, and a generated sa password that meets SQL Server complexity rules.
This listing replaces rotting marketplace clones that still ship mcr.microsoft.com/mssql/server:2022-latest (or a GitHub Dockerfile ARG TAG_NAME=2022-latest) with no CU pin.
About Hosting Microsoft SQL Server 2022 on Railway
Railway pulls the official Microsoft image mcr.microsoft.com/mssql/server:2022-CU26-ubuntu-22.04 (not :latest). A volume is mounted at /var/opt/mssql so databases survive redeploys. A TCP proxy on application port 1433 exposes SSMS / Azure Data Studio / sqlcmd access. Private networking is used for other services in the same project.
The start command is /opt/mssql/bin/sqlservr -T1800. Trace flag 1800 is required on Railway volumes (4K sectors); without it SQL Server can stack-overflow after misaligned IO on master.mdf.
SQL Server on Linux wants about 2 GB RAM. MSSQL_MEMORY_LIMIT_MB=2048 caps the engine so it does not size itself against the host.
Developer edition includes Enterprise features and is licensed for development and test only, not production. ACCEPT_EULA=Y means you agree to Microsoft’s SQL Server EULA.
First boot can take 1–2 minutes. Wait for SQL Server is ready for client connections in the deploy logs.
Common Use Cases
- App backends that speak TDS (Node
mssql, .NET, JDBC, Go, Python) against a privateMSSQL_URL - Local SSMS / Azure Data Studio connected through the public TCP proxy
- Dev and CI databases that need a current 2022 CU instead of an unpinned
:latesttag - Lift-and-shift prototypes that already assume SQL Server, not Postgres/MySQL/Redis
Dependencies for Microsoft SQL Server 2022 Hosting
- Image:
mcr.microsoft.com/mssql/server:2022-CU26-ubuntu-22.04 - Edition: Developer (
MSSQL_PID=Developer) - Volume:
/var/opt/mssql - Port:
1433(private + public TCP proxy) - Start command:
/opt/mssql/bin/sqlservr -T1800 - EULA: SQL Server container EULA
Deployment Dependencies
Generated (do not set on deploy)
| Variable | What it is |
|---|---|
MSSQL_SA_PASSWORD | sa password. Generated as Aa1!${{secret(32, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")}} so it always meets SQL Server complexity (upper, lower, digit, symbol, 8+ chars) without @/: breaking connection URLs. |
Required / fixed
| Variable | Default | Notes |
|---|---|---|
ACCEPT_EULA | Y | Required. Confirms the Microsoft EULA. |
MSSQL_PID | Developer | Edition or product key. |
MSSQL_USERNAME | sa | Built-in sysadmin. Cannot be renamed. |
MSSQL_TCP_PORT | 1433 | Private listen port. |
MSSQL_MEMORY_LIMIT_MB | 2048 | Caps SQL Server memory. |
RAILWAY_RUN_UID | 0 | Lets the volume at /var/opt/mssql be writable. |
RAILWAY_SHM_SIZE_BYTES | 268435456 | 256 MB /dev/shm. |
Private and public hosts
Other Railway services should use the private URL. SSMS / Azure Data Studio / local tools use the public TCP proxy.
| Variable | Value | Use |
|---|---|---|
MSSQL_SERVER | ${{RAILWAY_PRIVATE_DOMAIN}} | Private hostname |
MSSQL_TCP_PORT | 1433 | Private port |
MSSQL_SERVER_PUBLIC | ${{RAILWAY_TCP_PROXY_DOMAIN}} | Public TCP proxy hostname |
MSSQL_TCP_PORT_PUBLIC | ${{RAILWAY_TCP_PROXY_PORT}} | Public TCP proxy port |
MSSQL_URL | sqlserver://${{MSSQL_USERNAME}}:${{MSSQL_SA_PASSWORD}}@${{MSSQL_SERVER}}:${{MSSQL_TCP_PORT}} | Private connection URL |
MSSQL_URL_PUBLIC | sqlserver://${{MSSQL_USERNAME}}:${{MSSQL_SA_PASSWORD}}@${{MSSQL_SERVER_PUBLIC}}:${{MSSQL_TCP_PORT_PUBLIC}} | Public connection URL |
From another service in the same project:
${{MicrosoftSQL.MSSQL_URL}}
Drivers that need Encrypt (ADO.NET, recent mssql Node, JDBC):
Server=${{MicrosoftSQL.MSSQL_SERVER}},1433;User Id=sa;Password=${{MicrosoftSQL.MSSQL_SA_PASSWORD}};Encrypt=True;TrustServerCertificate=True
Public / off-Railway clients use MSSQL_SERVER_PUBLIC and MSSQL_TCP_PORT_PUBLIC instead.
How to log in
- Open the MicrosoftSQL service → Variables
- Copy
MSSQL_SA_PASSWORD - Private (same Railway project): host
MSSQL_SERVER, port1433, usersa - Public (SSMS, Azure Data Studio, local app): host
MSSQL_SERVER_PUBLIC, portMSSQL_TCP_PORT_PUBLIC, usersa - Enable encrypt + trust server certificate if the client requires TLS
sqlcmd example (public proxy):
sqlcmd -S "$MSSQL_SERVER_PUBLIC,$MSSQL_TCP_PORT_PUBLIC" -U sa -P "$MSSQL_SA_PASSWORD" -C -Q "SELECT @@VERSION"
Why Deploy Microsoft SQL Server 2022 on Railway
Railway handles the image pull, volume, private DNS, and TCP proxy. This template is healthier than rotting marketplace clones because it:
- Pins a CU tag (
2022-CU26-ubuntu-22.04), not:latest/2022-latest - Mounts a volume at
/var/opt/mssqlso data survives deploys - Starts with trace flag 1800 so Railway 4K volumes do not stack-overflow on misaligned IO
- Generates an SA secret that satisfies SQL Server password complexity
- Exposes TCP 1433 and documents private + public host/URL variables
- Sets Developer edition + EULA explicitly (
MSSQL_PID,ACCEPT_EULA=Y) - Caps memory with
MSSQL_MEMORY_LIMIT_MB=2048
Official Railway Postgres / MySQL / Redis templates are already healthy. This listing is MSSQL only.
By setting ACCEPT_EULA=Y you accept the SQL Server container EULA. Developer edition is not licensed for production.
Template Content
MSSQL_PID
Choose your licensed edition explicitly. Developer is development/test ONLY, never production. Production requires an eligible Express deployment or a properly licensed paid edition/product key; selecting a name does not grant a license.
ACCEPT_EULA
Required personal choice: read https://go.microsoft.com/fwlink/?LinkId=746388 and set Y only if you accept. No default acceptance.