Run ASP.NET Core 3.1 Apps in Docker with HTTPS.
HTML-код
- Опубликовано: 2 авг 2020
- In this step by step tutorial I take you through how to package your ASP.NET Core app as a Docker Image and then run your image as a Docker container with HTTPS Enabled. This includes creating a dedicated self-signed development certificate, configuring user secrets and passing in the necessary environment variables to the container to enable HTTPS.
We further configure this with Docker Compose for ease of use and reuse going forward.
Level: Beginner / Intermediate
📕 My Book: www.apress.com/gp/book/978148...
😍 Patreon Site (Exclusive Member Benefits!): / binarythistle
💻 Code on GitHub: github.com/binarythistle/S03E...
🔗 Install Docker Desktop Via WSL: docs.docker.com/docker-for-wi...
🔗 Docker Net Core Set Up: docs.docker.com/engine/exampl...
🔗 HTTPS & Docker Microsoft Doc: github.com/dotnet/dotnet-dock...
⏲️-Time Codes-⏲️
1:33 - Course Outline
3:13 - Demo
6:13 - Overview of Docker
10:23 - Scaffold Up API
18:40 - Build Docker Image
24:48 - Run Our Inage (without HTTPS)
27:39 - Some Container housekeeping
31:32 - Generate Dev Certifcate for Container
35:15 - Configuring User Secrets
42:12 - Rebuild our image (with User Secrets)
43:32 - Overview of Docker Run parameters
48:26 - Run our Container with HTTPS (Docker CLI)
49:40 - Migrate and Run in Docker Compose
56:40 - Certificate file name case sensitivity
58:20 - Final Thoughts
58:52 - Patreon Supporter Credits
This helped me immensely!! And was exactly the explanation I was looking for thanks. Will defiantly be watching more of your videos. Thanks
Les I cant thank you enough for your tutorials. I always find solutions to my problems from your videos. Big Thanks
Les, you are awesome!! I like all of your videos, you definitely deserve way more subs !
Really appreciate the clarity and completeness of the content. 👍👍 Very practical and just what I needed!! Thanks
This is absolutely awesome. Helped me get out of a week long block in my project. Thank you so much.
Video speed and amount of detail is spot on too.
thanks for such a wonderful video. I left your microservice video to come here and learn a bit more about docker (I felt like I was lacking some well needed info). I'm going back to continue. thank you for been a good teacher
Les , you are star mate !!
Absolutely amazing tutorial.
Amazing tutorial! Your content is simply superb. Keep up with the good work!
Your video's are great: not too slow, not too fast. Sound and image quality is good. All necessary details are mentioned. Really useful information, that I can apply in my projects.
the way you explain things is excellent! your video helped me a lot, thank you! Greetings from Argentina.
This is gold! I love the way you purposely show issues other will encounter rather than, and help them fundamentally understand what is going on, instead of just going through it the correct way first time around.
Thanks mate! Sometimes I think I over-explain, but I do like to point out areas where you could get tripped up, (because I do!). I actually think those areas are the parts where you learn the most anyway, so I'm glad you find the approach useful.
Thanks for the feedback, really appreciate it!
Les
Yesterday I learned about the docker and today you bring this video :) thanks a lot Les 🎉🎉
Hope you enjoyed it!
Thanks a lot for this video.You've excellently explained the https mechanism for asp.net core.
Les Jackson's channel is probably the best Learning Platform!! Thank you for all the awesome work
Wow! Thanks Abdul - that's really kind of you to say! Cheers Les
Excellent lecture :) Congrats, Les!
Thanks Cristiano!
Thanks for a great video, very clear and selection of level of detail.
thanks Jackson, This is an amazing sharing and super helpful for me and the details are very fantastic
Awsome explanation, awsome detailed, awsome clarification, awsome to find you to explain this :D
Great job Les! Thanks a lot for the great tutorial. Would have been great if you could have also explained what changes when deploying release image in production, but even ASIS this is a tutorial of a great value. Thanks again!
Wow, I am waiting for this type of lecture since long back. No time to do analysis and learn on my own. You became my God while in this Pandemic, not just because of this single video, but due to multiple Diamond like videos.
Hi Ashok - thank you my friend for those lovely words - I really appreciate it! Glad you're enjoying the videos, take care, Les
Thank you so much Les, much appreciated.
I also noted that the docker file name must be "Dockerfile" otherwise the docker-compose file will complain and wont build the image.
thanks bro for awesome explanation, very clear and easy to understand
Many thanks, very useful and easy steps otherwise would be painful. All the best..
Amazing in details dive inside docker..thank you so much
Excellent tutorial! Particularly happy to see you do it through VS code and will try to replicate this on a Mac!
Yeah, this is great that Les used VS Code.
Excellent tutorial, thanks a lot for clear instructions.
your videos are a life saver! keep it up.
Wow!!!! Thank you. You are a good instructor❤❤❤😊
I wish I would have found this video this morning because it would have saved me an entire day of swearing and reading a lot of things that might have worked in the past but don't anymore. Either way, thanks a lot!
xcellent tutorial, thanks a lot for clear instructions.
Thanks for making this video!
Incredible guide! Thanks!
Thanks. Fantastic job! Note: Amazon says you have 5 reviews on your book (average 4/5). But they only display the review by the guy who gave it a 2.
Thank you very much, especially at the time of the video 15:17.
Wow finally the wait is over :)
:)
Thank you so much, this helped a ton!
Awesome tutorial, thanks a lot ! :)
Thank you for the video sensei. Greating from Switzerland
Hey Maxime! Nice to hear from you again! Hope you're safe and well in Switzerland!
Locked down here in Melbourne, but we're all good!
Stay safe,
Les
@@binarythistlenice to hear that your safe and well too, I hope everything is going to be ok in Melbourne.
I m fine, Switzerland have ended the lock down we are doing fine here, I m still working from home and your videos are still very helpful :) thank you a lot.
Stay safe
i Absolute love this.... you help me a lot...
Fantastic content Les. You can hear the passion and commitment you have to the topic in all of your videos. Love listening, and working through them. I am a full stack consultant/developer but haven't really lived in the MS world at all. At 11:40 or so into the video you mention a command:
code -r WeatherAPI
which fails to work on my mac, after I had just installed the free version of vscode. Just a heads up that it might be something to mention to non-MS/vscode users out there.
Thanks again for sharing you experience.
I'm pretty late to the party, but to open a directory in code on Mac you can do code or if you're in the folder do code . to ref the current folder.
I must echo the messages below, as always outstanding content and very helpful. GOD bless you my friend.
Thanks mate, best wishes to you too from Melbourne!
You are the best! Hey people He is the best i have ever met! Thank you :)
Than you so much an excellent, well explained tutorial 😊
Just sharing what I learnt yesterday. You can simply scaffold Dockerfile from Command Palette by pressing Ctrl + Shift + P and look for "Add Dockerfile" (after Docker extension installed). This will prompt and auto-generate Dockerfile into your project
Thanks Jackson for your effort. You are the spider man of the dotnet.
Thanks Prasanth!
Thanks man, this really helped me
Thank you for the great content I learn a alot from your videos you are great
Thanks for that - you helped me a lot.
Thank you Les!
The best Channel, thanks
Wow, thanks!
Best video for this content I found on YT, I hope there is next video how we can hope this docker image on Kubernetes with HTTPS enabled, I tried to search it but not found it.
@binarythistle please do create content video for this.
thanks you for helping us.
Thank you so much, very helpful.
Superb content !
This helped a lot.
Thank you very much for this video, well explained and you helped me fix my issue .
Which was the case sensitivity of the certificate and also that it needs to have the same name as the entrypoint dll name.
Great job 🙂
This is a great video!
Great video!
Do you have a Production Environment Version of this tutorial? Still really good work on explaining how this works!
Did you ever find anything covering this? I need it desperately, my searches aren't turning up with much.
you are genius.. saved my day!!.. :)
Dear sir, great content.
It would be much appreciated if you could create a playlist with best practices and maybe some libraries you often use in daily work. (Mid-senior level would be best appreciated)
This is an excellent, well explained tutorial. One thing that I'm wondering though- what are the steps to HTTPS secure such containers in production? And also- how to do it when having 2 ASP Core APIs, each in its own container, and you want them to talk to each other over HTTPS?
Thank you!
Darn, just watched this after spending the day getting this implemented at work. Nice one. P.S. there is another environment variable for kestrel that allows you to specify the certificate name so that it doesn’t have to be named the same as the dll. Useful if you have multiple services using the same certificate (e.g. a wildcard one from a trusted CA).
Link to resource please
Not sure if there are any specific resources that cover this. But if you check out docs.microsoft.com/en-us/dotnet/core/additional-tools/self-signed-certificates-guide you will see that a path is specified for the certificate in the docker commands. Based on that you can define either an environment variable or specify the location in your app settings or secrets files.
@@whatizzydoin Thank you
Great work Les. Would be great to see how you would be able to use different sql connection strings in different environments. If you know where I could find this info that would also be great, thanks.
You can google it
This is really awesome thanks for this video, can you please make a video on handling the concurrency issues in web api core.
great stuff thanks
Perfect!!
Thanks Jackson, it's very useful for me. How to use SSL certificate docker container in AWS EC2
Thank you for this wonderful post. we would also like to see how this would work when we host it from linux container or linux machine. Love to know what are all the stuffs needs to be done in addition for Linux specially for making it a HTTPS.
Thank you
That is cool, thank you very much! Do you want to make a video about Redis or Memcached with .NET ?
Perfect!
Thanks for sharing. One more thing I want to add like can we have one demo for api gateway and multiple microservices with docker compose and how we can deployed in azure... if possible can you create video for that...
love it
Good base explanation and POC, but some areas that could use more info on:
* connecting to a db while using https (assuming secrets from azure or aws would be easiest for prod quality connection credentials)
* setting it up with nginx and certbot/lets encrypt
* doing this all at production quality. pet peeve of tutorials is *it's fine here, but don't do it in prod* that's not very useful for me 🤷🏼♂️
No dislakes. This is the most powerfull measure.
This was really fucking great. masterclass
You have done a great job here. May I know will you be making the the same thing using .net 5?
Nice bgm nice course
Hi Les, Thanks for nice video.. Do you have any suggstion to deploy docker image to azure ?
Wouldn't mind a video explaining how to set up Docker in WSL. I have tried and definitely run into issues.
Please create a video on microservice using gRpc and .net core + docker
I love You
Hi Les, Thanks for sharing such a wonderful video. could you please suggest some approach to run scheduled python script on azure which is making some calculation and storing result as CSV in Azure Blobs
Thanks for the video!
Can someone help me out applying this to a microservice architecture? Each service is happy to run in HTTPS, but breaks when it comes to communicating with each other. I think there is also an issue with docker-compose and how the DNS uses the image name as apposed to localhost.
Hi, Les! Thank you for this amazing video, surely helped me a lot. However, I have some questions about it. Is it possible to commit the certificate on Github so anyone who forks the project doesn't have to configure the certificate themselves? Is it possible to make this out of the box with docker? Cheers!
Hi Les, First, you are doing a great job on your videos, thanks for sharing. I have a question about running docker. I am using Visual Studio and added support for docker. When I run F5, it builds and loads the image in Docker Desktop. I am then able to navigate to the swagger document without an issue, but when I stop the debugger, I can no longer navigate to the swagger document even though the Docker Desktop shows the image is still running. Any Ideas? The second part is if I switch over to VS Code and go to the solution folder and try to manually build the image (I include -f [folder]\Dockerfile, the build process errors out with failed to compute cache key: I did change the . to the project folder
King
Hi, why you don't use more lightweight Alpine-based images? Thanks
@Les Jackson
#Les Jackson
Hi, I was wondering if there is a way to utilize Typescript with dotnet core 3.1 and web api? I would really love to see the use of Typescript in the backend on dotnet core.
For production, it is necessary to have the user secrets ?, or it would be enough to just specify the certificate path and password ?. I'm not sure how to do it.
You should do one with MSSQL database
Hi, Good video. i'm doing a image .net Core 3.1 for Debian 9 stretch. But I have error to image sdk version and image runtime version they aren't compatible. Only can I use .Net Core 2.1 for Debian 9 -stretch ?.
Hi. Can you teach us how we can deploy https in production? Thank you
Hi, I'm following this tutorial but whatever I do I still have this error, "System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer
certificate could not be found or is out of date." any solution?
Maybe because the password set for the certificate does not match your password in the secrets
normally I don't commented on any of this, but this video was very helpful, do you have any advice on put this into production or its the same configuration?
Hello, I'm new in docker world and I found this tutorial that help me to understand how to use https on the docker, but I have a question regarding the certificate, can I use one certificate for multiple API application? or we should generate one by one for every single API? thanks before
If youre getting this error;
Specify which project or solution file to use because this folder contains more than one project or solution file.
Add .csproj
RUN dotnet publish .csproj -c Release -o out
Instead of
RUN dotnet publish -c Release -o out