Search code examples
sql-serverdockerlocaldb

LocalDb V11.0 on Docker


I am using Visual Studio 2017 for my project but unfortunately there is no support for LocalDb V11. So I would like to have a Docker container with it but couldn't find any existing image for it. I'd like to have the following connection string to my DB:

"Data Source=(LocalDB)\\v11.0;Initial Catalog={0};Integrated Security=True; Trusted_connection=true;Connection Timeout=60"

So my question is there any Docker Sql-server image with LocalDb v11.0? Or is it possible to use official microsoft/mssql-server-linux either Linux or Windows?


Solution

  • I'm not aware of an official Docker image for LocalDB. You would need to build a custom (Windows) image from a dockerfile, installing LocalDB via command-line with RUN instructions. But since LocalDB does not allow remote connections, the implication is that you would also need to include your app and dependencies in the image too.

    Docker CE for Windows can run either Linux and Windows containers. However, both cannot (currently) run at the same time so you'll need to toggle between the 2 image types if you use both. SQL Server Linux images are lighter weight, allow different editions, and are supported in production. Windows images are needed if you have dependencies on features only available with SQL Server on Windows or prefer a Windows OS.

    For non-prod use, consider using the free Developer Edition (Linux or Windows). Developer edition has all the same features as Enterprise but may only be used for development and testing. A lesser edition doesn't provide benefit unless you need to run it in production and want to save costs.

    Below are links to the Docker Hub pages.

    SQL Server Windows images

    SQL Server Linux images

    Running either of these images with -p 1433:1433, you can use the connection string from your comment:

    "Server=localhost,1433;Initial Catalog={0};User ID=sa;Password=ComplexPW!123"?