dockersql-server-expressdocker-for-windowsdocker-desktopserver-core

SQL Server Express does not start on running docker container (Windows)


What I have done:

My Problem:
On container A the SQL Server works correctly.
On container B the SQL Server could not be started.
When I try to start the service with net start "SQL Server (INST)" i get following error:
A service specific error occured: 5.

What is the difference between these two containers?


Solution

  • Microsoft have their own image on the Docker Hub with SQL Server 2016 Express installed: microsoft/mssql-server-2016-express-windows. You can use that directly, or extend it with your own Dockerfile that starts:

    FROM microsoft/mssql-server-2016-express-windows
    

    If you'd rather build your own, you can see how Microsoft do it from their Dockerfile - and if you check the PowerShell script in the CMD instruction, it starts SQL Express like this:

    start-service MSSQL`$SQLEXPRESS
    

    When you use docker commit to save a changed image, you're not changing the CMD that Docker will use when you run a new container from the image, so you're better off building your image from a Dockerfile.

    As to why the service is failing to start in your container B - that depends on the steps you took to install SQL, and the options you used when running the containers.