
However, if you remove the container with docker rm, everything in the container is deleted, including SQL Server and your databases. Your SQL Server configuration changes and database files are persisted in the container even if you restart the container with docker stop and docker start. If you reversed the commands in the previous example, the container would shut down when the do-my-sql-commands.sh script completes. The following command illustrates this inside a Dockerfile: /usr/src/app/do-my-sql-commands.sh & /opt/mssql/bin/sqlservr All other commands are run in the background. For example, if you want to run a script and start SQL Server, make sure that the SQL Server process is the right-most command. If it exits, the container will shut down.

If you do create your own Dockerfile, be aware of the foreground process, because this process controls the life of the container. For more information, see a demo that combines SQL Server and a Node application. It is possible to create your own Dockerfile to create a customized SQL Server container.

This article explains how you can configure and customize SQL Server Docker containers, such as persisting your data, moving files from and to containers, and changing default settings. Applies to: SQL Server (all supported versions) - Linux
