.NET Docker Tutorial - SQL Server Docker [.NET Docker]

Sdílet
Vložit
  • čas přidán 6. 08. 2024
  • Microservice Architecture Playlist: Microservices Tutorial Playlist Link: • What are Microservices...
    This is .Net Core Docker Tutorial [.Net Docker Tutorial] that explains how to containerize .Net application with SQL Server Database. Visual Studio provides the options to easily develop applications with Docker Support, Debug with Docker [Docker .Net Core Debug], and Deploy the Docker Container [Deploy .Net Core to Docker].
    We are using the Official container image for Microsoft SQL Server on Linux for Docker Engine [SQL Server Docker]. We'll use this docker image for creating a container for SQL Server Database. Then the .Net Core application container can connect to the database container for read-write operations.
    In this .NET Docker tutorial, you'll learn how to manage more than one container and communicate between them when using Container Tools in Visual Studio. Managing multiple containers requires container orchestration and requires an orchestrator such as Docker Compose, Kubernetes, or Service Fabric. Here, we'll use Docker Compose. Docker Compose is great for local debugging and testing in the course of the development cycle. This is a very important video as it covers a major part of Docker .Net Core Microservices.
    Visual Studio provides a consistent way to develop Docker containers and validate your application locally. You can run and debug your apps in Linux or Windows containers running on your local Windows desktop with Docker installed, and you don't have to restart the container each time you make a code change.
    You can view what's going on inside the containers that host your app by using the Containers window. If you're used to using the command prompt to run Docker commands to view and diagnose what's going on with your containers, this window provides a more convenient way to monitor your containers without leaving the Visual Studio IDE.
    What is Docker Compose?
    Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
    Docker .Net Core:
    .NET Core can easily run in a Docker container. Containers provide a lightweight way to isolate your application from the rest of the host system, sharing just the kernel, and using resources given to your application. Learn how to use docker for .Net Core and deploy .Net Core to Docker.
    .NET Core images
    Official .NET Core Docker images are published to the Microsoft Container Registry (MCR) and are discoverable at the Microsoft .NET Core Docker Hub repository. Each repository contains images for different combinations of the .NET (SDK or Runtime) and OS that you can use.
    Microsoft provides images that are tailored for specific scenarios. For example, the ASP.NET Core repository provides images that are built for running ASP.NET Core apps in production.
    The tools included in Visual Studio for developing with Docker containers [.Net Core Docker Container] are easy to use, and greatly simplify building, debugging, and deployment for containerized applications. You can work with a container for a single project, or use container orchestration with Docker Compose or Service Fabric to work with multiple services in containers.
    Docker support in Visual Studio:
    Docker support is available for ASP.NET projects, ASP.NET Core projects, and .NET Core and .NET Framework console projects.
    The support for Docker in Visual Studio has changed over a number of releases in response to customer needs. There are two levels of Docker support you can add to a project, and the supported options vary by the type of project and the version of Visual Studio. With some supported project types, if you just want a container for a single project, without using orchestration, you can do that by adding Docker support. The next level is container orchestration support, which adds appropriate support files for the particular orchestrator you choose.
    Docker support for a .Net Project [Blazor Docker]:
    You can enable Docker support during project creation by selecting Enable Docker Support when creating a new project. You can add Docker support to an existing project by selecting Add - Docker Support in Solution Explorer. The Add - Docker Support and Add - Container Orchestrator Support commands are located on the right-click menu (or context menu) of the project node for an ASP.NET Core project in Solution Explorer.
    Video Chapters:
    0:00 - Video Summary
    1:12 - Project Setup
    4:23 - Adding Container Orchestration Support
    5:24 - Working with Docker Compose
    10:11 - Docker Networking Basics
    14:38 - Publish to Docker Hub Repository
    15:44 - Docker Compose Installation
    17:33 - Deploying the Application
    #CodingDroplets #Docker #Microservices

Komentáře • 94

  • @CodingDroplets
    @CodingDroplets  Před 2 lety

    ⭐ Join Us on Patreon: www.patreon.com/CodingDroplets
    Microservices Tutorial Playlist Link: czcams.com/video/gPInkLCfalE/video.html

  • @faviorequena7342
    @faviorequena7342 Před 6 měsíci +2

    I have spent a lot of time researching how to do this and you have done it and explained it in an incredible way. Thank you for this.

    • @CodingDroplets
      @CodingDroplets  Před 6 měsíci

      Glad to hear that you found the tutorial helpful!

  • @verbroez712
    @verbroez712 Před 4 dny +1

    Wow, this tutorial is awesome. Thanks ❤

  • @kittkillward9014
    @kittkillward9014 Před měsícem +1

    wow it feels nice when you follow tutorial and all works in the end (except part where I searched how to use sql server 2022 instead of 2019)

    • @CodingDroplets
      @CodingDroplets  Před měsícem

      I'm glad to hear the tutorial worked well for you! For using SQL Server 2022 you can use the SQL Server Docker image available at:
      mcr.microsoft.com/product/mssql/server/about

  • @muhammadzaakirmungrue3146

    People like you I encourage me to teach others because It's not always as easy as making a docker file and image and use the correct DB connection string .

    • @CodingDroplets
      @CodingDroplets  Před rokem

      Thank you for your kind words! I'm glad to hear that my tutorial has inspired you to teach others.

  • @refre07
    @refre07 Před 27 dny +2

    Nice video, It aswered the question I had on creating docker network. Thanks

    • @CodingDroplets
      @CodingDroplets  Před 23 dny

      Thank you! Glad to know the video answered your question.

  • @talkathiriify
    @talkathiriify Před 5 měsíci +2

    Excellent explanation ever for docker container and images.
    Thank you very much.

    • @CodingDroplets
      @CodingDroplets  Před 5 měsíci

      Thank you so much for your kind words! Glad to hear that.

  • @fisnik8965
    @fisnik8965 Před rokem +1

    Amazing tutorial with very valuable lessons in it. For me it was the networking part which gave me the answers I needed.

  • @DreamWalker886
    @DreamWalker886 Před 6 měsíci +1

    Very clear and concise

  • @gleamofcolor
    @gleamofcolor Před 5 měsíci

    Nice video, i am looking for this kind of videos. Thaks for your time and effort to make this video 😊

  • @gagecarpenter7532
    @gagecarpenter7532 Před rokem +2

    The Teacher I never had!

  • @bh4541
    @bh4541 Před 10 měsíci +4

    for someone who struggling when follow the video but cant access sql server after F5 , connectionstring should be
    $"Data Source=host.docker.internal;Database={dbName};User ID=sa;Password={dbPassword}";

  • @studycenter-za
    @studycenter-za Před 5 měsíci +1

    Great explaination. Thanks bud.

    • @CodingDroplets
      @CodingDroplets  Před 5 měsíci

      I'm glad you found the explanation helpful! Thank you for watching and for your feedback.

  • @paulpurington8637
    @paulpurington8637 Před rokem +1

    Great instructional video!!

    • @CodingDroplets
      @CodingDroplets  Před rokem

      Thank you so much for your positive feedback! I'm thrilled to hear that you found the instructional video great.

  • @suleymanyavas8806
    @suleymanyavas8806 Před 10 měsíci +1

    Thank you for this great tutorial.
    You explained it verry well!
    it helped me understand docker and docker compose.
    again thank you for the afford.

    • @CodingDroplets
      @CodingDroplets  Před 10 měsíci

      You're very welcome! I'm glad to hear that the tutorial was helpful and that it aided in your understanding of Docker and Docker Compose. Your kind words and appreciation mean a lot to me.

  • @omartorresrios8216
    @omartorresrios8216 Před rokem +1

    Your video is incredible, thanks for the information you share, the only thing missing from the video is talking about volumes.

    • @CodingDroplets
      @CodingDroplets  Před rokem +1

      Thank you for your positive feedback on the tutorial and for sharing your suggestion. I'm glad you found the video incredible and valuable.
      You're absolutely right that discussing volumes in the context of SQL Server Docker containers would have been beneficial in the tutorial. Volumes are an essential aspect of containerization, as they allow for persistent storage of data and can greatly enhance the flexibility and scalability of your containerized applications.
      While the specific topic of volumes was not covered in this particular video, I appreciate your feedback and will take it into consideration for future tutorials. In upcoming videos, I'll make sure to include discussions on volumes and their importance in containerized environments.

  • @chamarthi123ful
    @chamarthi123ful Před 2 lety +1

    Great explanation, Thank you. Waiting for next session.
    if possible can please do video on how microservice communicate to other microservice using service bus and any different ways

    • @CodingDroplets
      @CodingDroplets  Před 2 lety +1

      You are most welcome. Thank You for commenting your thoughts.
      This series named Microservice Architecture will be a beginner to advanced tutorial series.
      So initially we'll be developing the projects in a simpler way. Gradually we'll add more advanced functionalities to the series. So that the beginners will be able to understand concepts clearly.
      We'll be adding more functionalities like event bus, messaging protocols, background services to process long running tasks, gRPC API microservice etc in the later sessions.

  • @huseyinxdrov7403
    @huseyinxdrov7403 Před rokem +1

    soo nays
    👍

  • @user-qf5mr7nl8d
    @user-qf5mr7nl8d Před rokem +2

    You are awesome! Great video. Keep 'em coming.

    • @CodingDroplets
      @CodingDroplets  Před rokem

      Thank you so much for your enthusiastic comment! We're glad that you enjoyed the video and found it helpful.
      Your kind words and encouragement mean a lot to us. We're committed to creating more informative and engaging tutorials.

  • @necromanta2
    @necromanta2 Před 4 měsíci

    I did as in tutorial, but after download from docker hub and compose up when i try load page i am getting no response error

  • @OnTheSpurOfTheMoment
    @OnTheSpurOfTheMoment Před 6 měsíci +7

    But the data is gone once you bring it down. You should have included volumes in your tutorial.

    • @CodingDroplets
      @CodingDroplets  Před 6 měsíci +2

      Thank you for your feedback! You're absolutely right, and I appreciate your observation. Including volumes in a Docker setup is indeed a crucial aspect. I'll consider creating an additional tutorial that specifically covers the usage of volumes.

  • @user-xe6bo4yt2z
    @user-xe6bo4yt2z Před 10 měsíci +2

    thank you for this useful tutorial .. you said there are 2 networks but you created just one network (Backend) . can you explain more about the second network Frontend ??

    • @CodingDroplets
      @CodingDroplets  Před 10 měsíci +1

      Thank you for watching the tutorial! In this specific video, I used the concept of maintaining two networks as an example while discussing Docker networking. However, I want to inform you that in the next video of the series (which is already available in the playlist), I delve into the implementation of multiple network.
      Feel free to check out the next videos for a more comprehensive understanding of Docker networking with multiple networks.

  • @mohammadhaider8462
    @mohammadhaider8462 Před 2 lety +2

    Hi this video is very useful. can you please also use CICD pipelines using Azure DevOps and deploy it on Azure Container Registry and then on Kubernetes.

    • @CodingDroplets
      @CodingDroplets  Před 2 lety +1

      More videos are coming soon. Currently we are working on Kubernetes videos.
      Please follow the playlist: czcams.com/play/PLzewa6pjbr3JQKhB_U_FiuYwQC70i-TyU.html

  • @vishalpawarsblogs8077

    Very useful tutorial. But I am curious to know In production environment , is it good idea to use sql server as docker container?
    How to handle sql db passwords for production if we use azure to host both app and db. Can you suggest way to deal with it? I am making POC on same so i stucked around it.

    • @CodingDroplets
      @CodingDroplets  Před rokem +1

      In production, the deployment will be much easier if you use docker.
      We just need to install docker in the host machine and no other installations needed. If you use docker compose, using a single command we can deploy the entire solution with database(s) and all other dependencies. This video is part of a series (link below). I suggest you to watch other videos as well for getting a proper understanding.
      czcams.com/play/PLzewa6pjbr3JQKhB_U_FiuYwQC70i-TyU.html

  • @user-jg4lb9es7n
    @user-jg4lb9es7n Před rokem +1

    Hi! thank you very much for your video! Very simple!
    Is it possible to make the data not be deleted from the database every time the application is launched?
    And is it possible to somehow enter data into the database without prescribing CRUD? I usually enter the data in the SqlServer itself, but I don't know how to do it with the docker container. Thank you!

    • @CodingDroplets
      @CodingDroplets  Před rokem

      I apologize for missing your comment earlier, but I'm glad to see it now. Thank you for watching my video and for your kind words!
      To answer your questions, yes, it is possible to preserve data in the SQL Server database even after the application is relaunched. This can be achieved by using a named Docker volume to store the data persistently. In the docker-compose.yml file, you can add a named volume for the SQL Server container to mount as a data volume. This way, the data will persist even if the container is destroyed or recreated.
      As for entering data into the database without using CRUD operations, you can use a SQL client tool like SQL Server Management Studio to connect to the SQL Server container and execute SQL queries to insert data directly into the database.

  • @guillermomazzari4983
    @guillermomazzari4983 Před rokem +1

    Thanks for this wonderful series, I have a doubt, when you have to choose the target OS (Linux or Windows) if you choose Linux, does it mean it only works on Linux OS? if I wanted to run on both, would I have to create two docker files?

    • @CodingDroplets
      @CodingDroplets  Před rokem +1

      It is just the OS for the container. Linux containers can run on windows machines as well. You can install docker in windows and run linux containers in it.

    • @guillermomazzari4983
      @guillermomazzari4983 Před rokem

      @@CodingDroplets Great, thanks! Im currently watching your blazor tutorial series, love it!

  • @nhatnguyenthanh7991
    @nhatnguyenthanh7991 Před rokem +1

    Great Tutorial! I deployed application in docker containenr and connect them each other, But i cannot to run command dotnet ef migrations add createinitial to migration to database. Could you give me some recommend for this?

    • @CodingDroplets
      @CodingDroplets  Před rokem +1

      Thank you for watching the tutorial and trying out the deployment in a Docker container.
      Regarding the issue you are facing with running the "dotnet ef migrations add createinitial" command, it seems like the Entity Framework tools are not installed in your container image. You will need to install the tools in your container by adding the following command in your Dockerfile:
      RUN dotnet tool install --global dotnet-ef
      Alternatively, you can install the tools locally on your host machine and run the command outside of the container, by specifying the connection string to the SQL Server container.
      I hope this helps! Let me know if you have any further questions or issues.

  • @afonsocarvalho3124
    @afonsocarvalho3124 Před 3 měsíci

    It worked for my web api, I can access the swagger from the docker mapped port. But it did not apply the migrations.

  • @flyboyt6218
    @flyboyt6218 Před 19 dny +2

    Hi I’m a newbie straight out of college. How can I access the code to follow through this tutorial from start to finish. Are there any github links or any other ways around it

    • @CodingDroplets
      @CodingDroplets  Před 17 dny

      Welcome to the coding world! You can access the source code for this tutorial on our GitHub repository here:
      github.com/codingdroplets/DemoMicroserviceSolution

  • @zergzerg4844
    @zergzerg4844 Před 9 měsíci +1

    Hello? For what purpose some people include nginx into assembly if blazer works without it?

    • @CodingDroplets
      @CodingDroplets  Před 9 měsíci +1

      Hello! Including NGINX in a Docker container along with a Blazor app can serve various purposes, depending on the specific use case and requirements:
      - NGINX can act as a reverse proxy, forwarding incoming requests to the Blazor app. This can provide an additional layer of security and help to manage and optimize traffic between clients and your Blazor application.
      - If you have multiple instances of your Blazor app running in a cluster for scalability, NGINX can distribute incoming requests among these instances to balance the load and improve performance.
      - NGINX is efficient at serving static files (like CSS, JavaScript, and images). You can configure it to serve these files directly, relieving your Blazor app from handling such requests, which can improve performance.
      - NGINX can handle SSL termination, offloading the SSL/TLS encryption and decryption process, which can reduce the workload on your Blazor app and improve overall performance.
      - NGINX can be configured for caching, which can significantly speed up the delivery of content to users, especially for frequently requested resources.

    • @zergzerg4844
      @zergzerg4844 Před 9 měsíci +2

      @@CodingDroplets Thanks a lot for your response, now I've got it.

    • @CodingDroplets
      @CodingDroplets  Před 9 měsíci

      You are most Welcome!

  • @labibabdullah389
    @labibabdullah389 Před 2 lety +1

    Will you be able to make a video on deploying this app to heroku (using docker)?

    • @CodingDroplets
      @CodingDroplets  Před 2 lety +1

      More videos are coming soon. Will try to include that as well.
      Please follow the playlist: czcams.com/play/PLzewa6pjbr3JQKhB_U_FiuYwQC70i-TyU.html

  • @vishalpawarsblogs8077
    @vishalpawarsblogs8077 Před 2 lety +1

    how does table created in sql image? do we need to run migration first?

    • @CodingDroplets
      @CodingDroplets  Před 2 lety

      In the Database Context contructor, you can see an object named databaseCreator with which I'm creating database and tables.

  • @joao-no5oj
    @joao-no5oj Před 5 měsíci +1

    3:03 How can I port myself at server startup using ef migrations?? This work? Or I need to use Database.Migrations()

    • @CodingDroplets
      @CodingDroplets  Před 5 měsíci

      To automatically apply EF migrations at server startup in a Docker container, you can use the approach of applying migrations by calling Database.Migrate() during the application startup.

  • @LoneLatinGuy74
    @LoneLatinGuy74 Před rokem +1

    I think is a good series, but would you have the source code to download for the blazer project?

    • @CodingDroplets
      @CodingDroplets  Před rokem

      Thank you for your positive feedback. I'm glad to hear that you found it helpful.
      Regarding your question, yes, all the source codes for the projects in the series, including the Blazor project, are available for download on my GitHub repository at github.com/codingdroplets

  • @winstochurgle9133
    @winstochurgle9133 Před rokem +1

    I can't get any succesful response from my web api. I'm getting this error: Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot authenticate using Kerberos. Ensure Kerberos has been initialized on the client with 'kinit' and a Service Principal Name has been registered for the SQL Server to allow Kerberos authentication. Any possible solution?

    • @winstochurgle9133
      @winstochurgle9133 Před rokem +1

      After solving error above using "integrated security=false" statement have this error:
      Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user 'sa'.
      at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)

    • @CodingDroplets
      @CodingDroplets  Před rokem +2

      Thank you for reaching out and sharing the error message you're encountering. The error message indicates a login failure for the 'sa' user in the SQL Server database.
      To troubleshoot this issue, I recommend the following steps:
      Double-check the connection string in your application. Ensure that the username and password for the 'sa' user are correct. Make sure there are no typos or missing information in the connection string.
      Verify that the SQL Server instance is running and accessible. Ensure that the server name, port, and any necessary network configurations are accurate.
      Test the connection to the SQL Server database using a database management tool like SQL Server Management Studio. This can help verify if the issue is specific to the application or if it's a configuration problem on the database server.
      If you're still experiencing issues after following these steps, I encourage you to review the source code of the project. It may provide further insights into the configuration and setup. You can find the source code at the following GitHub repository: GitHub - codingdroplets/DemoBlazorServerAppWithDockerCompose.

  • @gameportalhub
    @gameportalhub Před měsícem +1

    Hi. I am press docker-compose on visual studio, api starting on localhost. Everything working fine. But when i take build to compose, it is starting but i am not access from it’s ip. How can i start my api an spesific ip and access to it.

    • @gameportalhub
      @gameportalhub Před měsícem +1

      I am sorry. My mistake. I send request to api’s container ip. But when i use my device ip for request it respond.

    • @CodingDroplets
      @CodingDroplets  Před měsícem

      I'm glad you figured it out. It's common to run into such issues when working with Docker and network configurations.

  • @davidemmanuel3001
    @davidemmanuel3001 Před rokem +1

    great tutorial. Please can you share the code repo?

    • @CodingDroplets
      @CodingDroplets  Před rokem +1

      github.com/codingdroplets/DemoBlazorServerAppWithDockerCompose

  • @AccountZhykhor
    @AccountZhykhor Před rokem +1

    IDK why but it starts really slow. Any tips how i can debug it or common tips how can i make it load faster?

    • @AccountZhykhor
      @AccountZhykhor Před rokem

      I mean it builds fast (like 1-2sec) but browser starts in 4-5 minutes

    • @CodingDroplets
      @CodingDroplets  Před rokem

      Please check your Docker host's resources (CPU, memory, etc.). If your host machine is running low on resources, it can impact the performance of your Docker containers.

    • @AccountZhykhor
      @AccountZhykhor Před rokem

      @@CodingDroplets It has enough, takes around 0.5% of CPU and others 2% or smth like that

  • @facuoubel
    @facuoubel Před 4 měsíci +1

    I couldn't find the microsoft sql server image in dockerhub :(

    • @CodingDroplets
      @CodingDroplets  Před 4 měsíci +1

      hub.docker.com/_/microsoft-mssql-server

    • @facuoubel
      @facuoubel Před 4 měsíci

      ​@@CodingDroplets I have a problem with the docker-compose.yml file. When I configure the file and try to rebuild the application with Visual Studio Community, the application does not respond.

  • @khauvannam
    @khauvannam Před 3 měsíci +1

    Please help me, i stuck at error 40, i can accessable when using client like data grip or mssm, but when i send q request, it return server not accessable, ef core tool migration work fine...

    • @CodingDroplets
      @CodingDroplets  Před 3 měsíci

      It sounds like there might be a network configuration issue. Error 40 usually indicates a network-related error, where the client can't reach the SQL Server. Make sure that your Docker container is running and that it's exposing the correct port. Also, ensure that the connection string in your application points to the correct address and port where SQL Server is running.

    • @khauvannam
      @khauvannam Před 3 měsíci

      @@CodingDroplets the error belong to my docker container of my endpoint, i dont know why it happened, sql server work fine

    • @khauvannam
      @khauvannam Před 3 měsíci

      @@CodingDroplets hello there,the method without ef core work fine but the method with efcore still return 40 error, i dont know why it happen? What i should check it because my connection string still work fine with ef core tool

    • @khauvannam
      @khauvannam Před 3 měsíci

      ​@@CodingDroplets hi dbname is the database name you created in sql server manager before?

    • @CodingDroplets
      @CodingDroplets  Před 3 měsíci +1

      Kindly check the network is configured properly in docker-compose

  • @rafysancheztilogica8587
    @rafysancheztilogica8587 Před 11 měsíci +1

    volumes ?

    • @CodingDroplets
      @CodingDroplets  Před 11 měsíci

      Thank you for your question! In the tutorial video, we focused on containerizing a .NET Core app with an SQL Server database without explicitly discussing volumes. While volumes weren't covered in this particular video, they are indeed a crucial aspect of Docker.
      If you're interested in incorporating volumes into your Docker setup for data persistence, you can achieve this by modifying the docker-compose.yml file. Including volume definitions in the docker-compose.yml allows you to map paths on the host system to paths within the containers, thus ensuring data persistence even when containers are stopped or removed.

  • @paulsean5367
    @paulsean5367 Před 5 měsíci +1

    Hello,
    Thanks. But can we have the github link also ?

    • @CodingDroplets
      @CodingDroplets  Před 5 měsíci

      github.com/codingdroplets/DemoBlazorServerAppWithDockerCompose

    • @paulsean5367
      @paulsean5367 Před 5 měsíci

      thanks
      @@CodingDroplets