---
title: "Discussion on \"How to run ASP.NET Core & SQL Server from Docker\" | Hashnode"
description: "Discussion on \"How to run ASP.NET Core & SQL Server from Docker\". I've recently gotten into using Docker in my development cycle and I'm really enjoying how much of a wonderful tool it is. One thing that always used to be a pain was setting up a development server to run SQL Server. Now with Docker, I can just spin..."
url: "https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to run ASP.NET Core & SQL Server from Docker](https://samwalpole.com/how-to-run-aspnet-core-and-sql-server-from-docker?utm_source=hashnode&utm_medium=feed)

I've recently gotten into using Docker in my development cycle and I'm really enjoying how much of a wonderful tool it is. One thing that always used to be a pain was setting up a development server to run SQL Server. Now with Docker, I can just spin...

Oct 24, 2020 · 8 min read · samwalpole.com  
Updated Aug 25, 2024  
Read the article

-   [#docker](https://hashnode.com/tag/docker)
-   [#dotnetcore](https://hashnode.com/tag/dotnetcore)
-   [#aspnet-core](https://hashnode.com/tag/aspnet-core)
-   [#csharp](https://hashnode.com/tag/csharp)

## Written by

[Sam Walpole](https://hashnode.com/@dr_sam_walpole)

@dr\_sam\_walpole · United Kingdom

  
[View profile](https://hashnode.com/@dr_sam_walpole)

👨‍💻 Fullstack .NET and JavaScript teacher and advocate 👨‍💻

## Responses 11

Markdown supported · ⌘↵ to post

[Nicolás Fernández](https://hashnode.com/@panife)

[May 13, 2023](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/645f11f54824b288fcf10659)

Can you explain me the process to make the same whit a Console Application please

[John Pankowicz](https://hashnode.com/@johnp)

[Mar 1, 2022](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/621d7c9c085330c3f79c7490)

Thanks for the great article.

After cloning your project, I thought I would also be able to build & run the containers with "docker-compose up". But I encountered many problems. (Unable to start Kestrel, db login failure, db seed failure). I would solve one problem and find another.

I finally realized that the containers can only be built successfully by running the docker-compose (.dcproj) project. When that runs, entirely different Dockerfiles and docker-compose.yml files are used, as can be seen in the "container tools" output window.

In other words, if I use Visual Studio to create docker containers, it appears that only developers who use VS will be able to work on the project. This would be a problem on an open source project, where developers are using many different tools. Is this a fair assessment?

[MahmoudAbojahel](https://hashnode.com/@MahmoudAj)

[Dec 1, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/61a76b874b0b9223386b9129)

Thanks for sharing such a perfect article

[Tim](https://hashnode.com/@cirrus42)

[Oct 3, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/6159ee0ae2f1936f70b285ed)

Hi Sam, Great article. I am new to Docker and so please forgive my ignorance ;). I am an experienced .net developer and to save time I have literally downloaded your code as it is as my goal is to learn how to deploy .net code with SQL server to Docker. I have followed your instructions and everything works from Visual Studio as expected, however as soon as I close Visual studio the containers in Docker are gone (although the images remain). My assumption is that the environments/containers are purely a development construct. So my question is once I have developed my application and it works as expected, how do I go about deploying it to a docker container as a finished product?

[Yash Tiwari](https://hashnode.com/@Coursesity)

[Sep 16, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/61431ee42d0e2479882a1cdf)

Amazing article man! I have bookmarked this along with other resources of [free Docker tutorials](https://blog.coursesity.com/best-docker-tutorials/).

[Sam Walpole](https://hashnode.com/@dr_sam_walpole)

[Sep 16, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/61431ee42d0e2479882a1cdf#reply-614366132d0e2479882a289a)

Thanks a lot for your kind comments :)

[vilem cech](https://hashnode.com/@YesUNo)

[Feb 14, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/60292862355c6669fd17bd01)

Really good article. Helped me a lot. Only thing i had to change was omitting exposure of the ports in the dockerfile and app.UseHttpsRedirection(); in Startup. Tbh i dont know why it didnt work for me, probably my ports arent set up correctly. Other then that i have my app running on localhost now, so thanks a lot.

[Alex Hay](https://hashnode.com/@Legs)

[Jan 22, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/600aefd5a9a6c21e4fa45233)

Hi Sam,

Thanks for the guides, they've been super helpful :)

Having an issue with this one though. When I run the solution from your GitHub through the Docker Compose project the page `[localhost/weatherforecast](https://localhost:49167/weatherforecast)` then loads up with the message `localhost refused to connect.`

The NotesController page does the same thing and I can see breakpoints in the constructors aren't hit, although I have no issue stepping through the code in Program or Startup.

Looking at Docker Desktop and clicking open in browser from the DockerCompose container (created from the solution) and clicking `Open in Browser` takes me to `[localhost](http://localhost:1433/)` which gives the error `localhost didn’t send any data.`

If I look at the log for the SQL Server container I can see `Logon Login failed for user 'sa'. Reason: Failed to open the explicitly specified database 'AppDbContext'. [CLIENT: 172.22.0.3]` before it starts up the database.

I assume this is the issue - any idea how to resolve or debug this further?

I've tried adding my own secure password for the SQL instead of the one in your solution, several different ones with the same results.

[Alex Hay](https://hashnode.com/@Legs)

[Jan 22, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/600aefd5a9a6c21e4fa45233#reply-600af707a9a6c21e4fa452bb)

Restarted my computer and now it works fine _shrugs_

[Sam Walpole](https://hashnode.com/@dr_sam_walpole)

[Jan 23, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/600aefd5a9a6c21e4fa45233#reply-600bd3248304951e7434e969)

[Alex Hay](https://hashnode.com/@Legs) Ah that's odd. At least it's working now! I've sometimes had issues where the .NET container gets created before the SQL container, which throws a similar error. Restarting the project usually fixes that.

[Antonio Nicasio](https://hashnode.com/@TheDevDude)

[Jan 21, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/6009c0ee2e485f76d6daec0e)

Quick question I'm no expert in C# and .Net Core Technologies, my question is this docker implementation can work with an N-tier project solution?

[Sam Walpole](https://hashnode.com/@dr_sam_walpole)

[Jan 21, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/6009c0ee2e485f76d6daec0e#reply-6009c62820259176b15eaea3)

Hi Antonio, Thanks for the question. I presume that each of your tiers is just class libraries that are referenced by your application project? If so, yes it will work fine :)

[Antonio Nicasio](https://hashnode.com/@TheDevDude)

[Jan 21, 2021](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/6009c0ee2e485f76d6daec0e#reply-6009cb9020259176b15eaee8)

yes, the other tiers are just layer classes for logic business, etc. [Sam Walpole](https://hashnode.com/@dr_sam_walpole) thank you for the quick response.

[Antonio Matušan](https://hashnode.com/@fjaka)

[Dec 9, 2020](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/5fd0d6d849835e38d0a9b88c)

Hi Sam, thanks for the tutorial, it clarified a few things for me. I have followed the steps and everything was working with the docker, mssql server got up and my page was loading. After not doing anything on the project for 2 days, I came back and pressed "docker compose" in visual studio. I got an error (no matching manifest for linux/amd64 in the manifest list entries).

I was thinking of recreating the whole process but with the only exception of choosing Windows as an OS for Docker Compose.

Does this problem have anything to do with this? I am running Docker on Windows 10.

Thanks!

[Sam Walpole](https://hashnode.com/@dr_sam_walpole)

[Dec 13, 2020](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/5fd0d6d849835e38d0a9b88c#reply-5fd633eaf60e3973bae6c4cb)

Hi Antonio, I'm sorry that you are getting those errors - it's not something that I have experienced myself. Perhaps this page might be useful to you? [stackoverflow.com/questions/48066994/docker-no-ma…](https://stackoverflow.com/questions/48066994/docker-no-matching-manifest-for-windows-amd64-in-the-manifest-list-entries)

[Bob](https://hashnode.com/@Bob202)

[Dec 6, 2020](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/5fcd44e6f4006d0b1bedfdc4)

Great article! The only problem I faced is that each time I run the docker-compose project it results in a new SQL container being created and all my data is lost after each run! Do you have any solutions?

[Sam Walpole](https://hashnode.com/@dr_sam_walpole)

[Dec 13, 2020](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/5fcd44e6f4006d0b1bedfdc4#reply-5fd6339cf60e3973bae6c4c7)

Hi Bob, Thanks for the comment. I can't say that I've experienced the same issue - my Docker containers retain data between runs, unless I explicitly delete them. This article might have some useful tips to help you with persisting your data - [centinosystems.com/blog/sql/persisting-sql-server…](https://www.centinosystems.com/blog/sql/persisting-sql-server-data-in-docker-containers-part-1/)

[Rajeev Ranjan Roy](https://hashnode.com/@Rajeevroy)

[Oct 27, 2020](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/5f978815b4e415193fa1d18b)

Hi Sam, Thanks for sharing such a nice article. I have followed your steps and getting one issue while testing it through swagger. I am getting a sqlexception "Notes object not found", tried to check by debugging code stating from Main. I can see the same error under dbcontext object. Hope you would understand the issue. if you can guide me to pass through this exception.

[Rajeev Ranjan Roy](https://hashnode.com/@Rajeevroy)

[Oct 27, 2020](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/5f978815b4e415193fa1d18b#reply-5f97b283b4e415193fa1d33e)

I am able to resolve this issue, forgot to add initial migrations.

[Sam Walpole](https://hashnode.com/@dr_sam_walpole)

[Oct 27, 2020](https://hashnode.com/posts/how-to-run-aspnet-core-and-sql-server-from-docker/5f944d7540346172a86c1b05/comment/5f978815b4e415193fa1d18b#reply-5f97e1a091c85e2865f5e949)

[Rajeev Ranjan Roy](https://hashnode.com/@Rajeevroy)

Hi Rajeev, Thank you for the comments. I'm glad you managed to resolve your issue. It's my mistake that I forgot to write about adding the migration in this post. I will update it shortly.

Many thanks
