Running SQL Server on Linux or in Docker is great, but restoring from a .bak backup file requires a slightly different workflow than on Windows.

Step 1: Copy the backup file into the container

If you’re running SQL Server in Docker, first copy the backup file into the container:

docker cp my-database.bak sql-container:/var/opt/mssql/backup/

Step 2: Restore the database

Connect to the SQL Server instance using sqlcmd and run the restore command:

RESTORE DATABASE MyDatabase
FROM DISK = '/var/opt/mssql/backup/my-database.bak'
WITH MOVE 'MyDatabase' TO '/var/opt/mssql/data/MyDatabase.mdf',
     MOVE 'MyDatabase_Log' TO '/var/opt/mssql/data/MyDatabase_log.ldf'

Step 3: Verify

Check that the database was restored successfully:

SELECT name, state_desc FROM sys.databases

The MOVE clauses are important because the file paths in the backup will reference Windows paths that don’t exist on Linux. You need to redirect them to the Linux-appropriate locations.