Deploy Microsoft SQL Server 2022

Pinned SQL Server 2022 CU Developer, volume, TCP 1433, generated SA secret.

Deploy Microsoft SQL Server 2022

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 private MSSQL_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 :latest tag
  • 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)
VariableWhat it is
MSSQL_SA_PASSWORDsa 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
VariableDefaultNotes
ACCEPT_EULAYRequired. Confirms the Microsoft EULA.
MSSQL_PIDDeveloperEdition or product key.
MSSQL_USERNAMEsaBuilt-in sysadmin. Cannot be renamed.
MSSQL_TCP_PORT1433Private listen port.
MSSQL_MEMORY_LIMIT_MB2048Caps SQL Server memory.
RAILWAY_RUN_UID0Lets the volume at /var/opt/mssql be writable.
RAILWAY_SHM_SIZE_BYTES268435456256 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.

VariableValueUse
MSSQL_SERVER${{RAILWAY_PRIVATE_DOMAIN}}Private hostname
MSSQL_TCP_PORT1433Private 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_URLsqlserver://${{MSSQL_USERNAME}}:${{MSSQL_SA_PASSWORD}}@${{MSSQL_SERVER}}:${{MSSQL_TCP_PORT}}Private connection URL
MSSQL_URL_PUBLICsqlserver://${{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

  1. Open the MicrosoftSQL service → Variables
  2. Copy MSSQL_SA_PASSWORD
  3. Private (same Railway project): host MSSQL_SERVER, port 1433, user sa
  4. Public (SSMS, Azure Data Studio, local app): host MSSQL_SERVER_PUBLIC, port MSSQL_TCP_PORT_PUBLIC, user sa
  5. 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/mssql so 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

More templates in this category

View Template
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play.

PROJETOS
8
View Template
Redis
Self Host Latest Redis with Railway

7
View Template
EasyImg
Simple self-hostable Nuxt.js personal image hosting system.

Muhammad Bilal
0