<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: StackUpDev</title>
    <description>The latest articles on DEV Community by StackUpDev (@rajat_srivas).</description>
    <link>https://dev.to/rajat_srivas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F334745%2F51dba783-befc-4072-96cd-4572e64ff1a5.jpeg</url>
      <title>DEV Community: StackUpDev</title>
      <link>https://dev.to/rajat_srivas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajat_srivas"/>
    <language>en</language>
    <item>
      <title>Getting Started with DockerFile for Asp.Net Core</title>
      <dc:creator>StackUpDev</dc:creator>
      <pubDate>Wed, 09 Jun 2021 10:43:25 +0000</pubDate>
      <link>https://dev.to/rajat_srivas/getting-started-with-dockerfile-for-asp-net-core-1ikb</link>
      <guid>https://dev.to/rajat_srivas/getting-started-with-dockerfile-for-asp-net-core-1ikb</guid>
      <description>&lt;p&gt;So over the past few days I have been working on a .Net Core API which was using SQL Server via the Entity Framework Core. Now since I am using M1 Mac the only way to achieve this was by running the SQL Server on docker.&lt;/p&gt;

&lt;p&gt;The implementation was straight forward but running the entire app on docker was bit tricky and it took some time to figure it out. So once I was successful, I thought why not jot down my understanding of the docker file created by Visual Studio and how I completed this task&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio IDE or Visual Studio Code along with Asp.Net Core framework&lt;/li&gt;
&lt;li&gt;Docker Desktop up and running on the system&lt;/li&gt;
&lt;li&gt;Dot Net API Solution, the one I am using has a dependency on SQL Server (&lt;a href="https://github.com/rajat-srivas/GallaSoft.RetailerOnboarding" rel="noopener noreferrer"&gt;https://github.com/rajat-srivas/GallaSoft.RetailerOnboarding&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Requirement
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We need to run the application entirely via docker &lt;/li&gt;
&lt;li&gt;SQL Server container should be up and running before the .Net container as it is required for seeding the initial database using the Entity Framework migrations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Creating the Docker File
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;So I believe that you already have a project ready on which we are going to follow this step&lt;/li&gt;
&lt;li&gt;We will use the default dockerfile generated via Visual Studio for our implementation&lt;/li&gt;
&lt;li&gt;To add Docker Support: Right click on the Project &amp;gt;&amp;gt; Add &amp;gt;&amp;gt; Docker Support&lt;/li&gt;
&lt;li&gt;This will create three files in the solution, Dockerfile, docker-compose.yml and dockerignore&lt;/li&gt;
&lt;li&gt;We are going to focus on the first two files and understand it content&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dockerfile
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["GallaSoft.RetailerOnboardingAPI/GallaSoft.RetailerOnboardingAPI.csproj", "GallaSoft.RetailerOnboardingAPI/"]
RUN dotnet restore "GallaSoft.RetailerOnboardingAPI/GallaSoft.RetailerOnboardingAPI.csproj"
COPY . .
WORKDIR "/src/GallaSoft.RetailerOnboardingAPI"
RUN dotnet build "GallaSoft.RetailerOnboardingAPI.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "GallaSoft.RetailerOnboardingAPI.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "GallaSoft.RetailerOnboardingAPI.dll"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let's break down these 4 stages here and try to get some more detailed info about each and every one of them&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;FROM&lt;/strong&gt; command is used to specify the base image which is the Asp.Net 5.0 runtime environment required to run dot net based applications and name it is as base here&lt;/li&gt;
&lt;li&gt;We then use the &lt;strong&gt;WORKDIR&lt;/strong&gt; command to change the working directory for subsequent instructions in the Dockerfile&lt;/li&gt;
&lt;li&gt;We also expose the ports 80 and 443
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["GallaSoft.RetailerOnboardingAPI/GallaSoft.RetailerOnboardingAPI.csproj", "GallaSoft.RetailerOnboardingAPI/"]
RUN dotnet restore "GallaSoft.RetailerOnboardingAPI/GallaSoft.RetailerOnboardingAPI.csproj"
COPY . .
WORKDIR "/src/GallaSoft.RetailerOnboardingAPI"
RUN dotnet build "GallaSoft.RetailerOnboardingAPI.csproj" -c Release -o /app/build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now in this stage we are actually building our project and just before that we run the &lt;strong&gt;restore&lt;/strong&gt; command to make sure all dependencies are resolved&lt;/li&gt;
&lt;li&gt;We are also changing the base image and working directory of our container here&lt;/li&gt;
&lt;li&gt;The base image is now the dotnet sdk named as &lt;strong&gt;build&lt;/strong&gt; which is required to build and restore our project &lt;/li&gt;
&lt;li&gt;Working directory is changed as we want to keep the size of eventual container as small as possible and we dont need the sdk as we will require only the published file in the image&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;COPY&lt;/strong&gt; command is used to copy the content from source to destination. Here being from the project directory to the WORKDIR&lt;/li&gt;
&lt;li&gt;Then we run the &lt;strong&gt;dotnet restore&lt;/strong&gt; command on the project, copy everything to the WORKDIR&lt;/li&gt;
&lt;li&gt;We then build the project in Release mode and specify the output directory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM build AS publish
RUN dotnet publish "GallaSoft.RetailerOnboardingAPI.csproj" -c Release -o /app/publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now we have the build files of our project and next step is to use the build base image to publish our project in the output directory specified
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "GallaSoft.RetailerOnboardingAPI.dll"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the final stage we again go back to the base image of dotnet runtime as we dont need the build sdk anymore&lt;/li&gt;
&lt;li&gt;We only copy the entire content of the publish folder to our image&lt;/li&gt;
&lt;li&gt;Finally, we just specify the &lt;strong&gt;ENTRYPOINT&lt;/strong&gt; which will be used to run the app when the container is ran using this dockerfile&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now since we have gone through the Dockerfile which was created, we move on to the docker-compose.yml file which is actually used to build this project using the dockerfile&lt;/p&gt;

&lt;p&gt;We will have to create this on our own and let's discuss how we have done this for our usecase&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker Compose
&lt;/h3&gt;

&lt;p&gt;If your project doesn't have any dependency that needs to be locally present, then the docker-compose file will only have instruction to create and run a container from the dockerfile. &lt;/p&gt;

&lt;p&gt;But since here we need to have the SQL Server running before the dotnet project is ran, we specify and create this dependency&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '1.4'

services:

  db:
   image: "mcr.microsoft.com/azure-sql-edge"
   container_name: sql-server-db
   ports:
      - 1433:1433
   environment:
      - SA_PASSWORD=MyPass@word
      - MSSQL_PID=Developer
      - ACCEPT_EULA='Y'


  gallasoft.retaileronboardingapi:
    image: ${DOCKER_REGISTRY-}gallasoft
    ports:
       - 49838:443
    build:
      context: .
      dockerfile: GallaSoft.RetailerOnboardingAPI/Dockerfile
    depends_on:
      - db

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For our API to run, we need to two services to be running on the docker container, the db which refers to the SQL Server instance and the API project itself&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: I am using the Azure SQL Edge version of SQL and not the SQL Server since at the time implementation this was the best way to run an instance of sql server on M1 powered MacBooks.&lt;/p&gt;

&lt;h4&gt;
  
  
  db Service
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The properties mentioned here are similar to the one used while we run the container using the &lt;strong&gt;docker run&lt;/strong&gt; command&lt;/li&gt;
&lt;li&gt;We specify the image, container name, ports and the password which will be used to the access the server&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  api Service
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This step is to use the Dockerfile and create and run image &lt;/li&gt;
&lt;li&gt;The important thing here is the &lt;strong&gt;depends_on&lt;/strong&gt; tag which specifies that this service depends on the db service and hence, it must be up and running for seeding data before we run it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, that is all the overhead which is required to containerise our dot net core apps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/dQkcf8GANR0ps57oBH/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/dQkcf8GANR0ps57oBH/giphy.gif" alt="So Simple Gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, we can now either run the docker compose command from command prompt/terminal or Run the project from Visual Studio directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We should have the API project running in the browser and the two docker containers running as well. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftzi3s2q2dvddaanglofj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftzi3s2q2dvddaanglofj.png" alt="Docker Asp.Net Core Running Api"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wplfrj96f6clg7bv5x8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0wplfrj96f6clg7bv5x8.png" alt="Docker Container running"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks people if you reached till here. You guys are awesome. Keep learning, keep building 🚀🚀🚀🚀🚀🚀&lt;/p&gt;

</description>
      <category>devops</category>
      <category>aspnetcore</category>
      <category>dotnet</category>
      <category>programming</category>
    </item>
    <item>
      <title>Creating a custom SQL Server Docker Image on top of the Official Image</title>
      <dc:creator>StackUpDev</dc:creator>
      <pubDate>Wed, 09 Jun 2021 06:48:48 +0000</pubDate>
      <link>https://dev.to/rajat_srivas/creating-a-custom-sql-server-docker-image-on-top-of-the-official-image-1b78</link>
      <guid>https://dev.to/rajat_srivas/creating-a-custom-sql-server-docker-image-on-top-of-the-official-image-1b78</guid>
      <description>&lt;p&gt;Hello people, so today let's discuss how we can create our own custom SQL Server image on top of the official image. &lt;/p&gt;

&lt;p&gt;This can be really useful in multiple scenarios like when we have a new team member joining our team. Instead of giving them a fresh instance of SQL Server we can have an image of the initial setup and they can just pull it and be ready to work on it&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Docker Desktop up and running on the machine. Can be download from here &lt;a href="https://docs.docker.com/v17.09/docker-for-windows/install/"&gt;https://docs.docker.com/v17.09/docker-for-windows/install/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Account on Docker Hub so that we can publish and then pull our custom Sql Server docker image&lt;/li&gt;
&lt;li&gt;Running instance of a fresh SQL Server container from the official image available on docker hub mcr.microsoft.com/mssql/server:2017-latest.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -e "ACCEPT_EULA=Y" "SA_PASSWORD=MYPASSWORD123" -p 1433:1433 --name MyContainerName -d mcr.microsoft.com/mssql/server:2017-latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up the SQL Server 🔥
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Once we have the server up and running, login to the SQL Server using SQL Server Management studio with the IP address of the host&lt;/li&gt;
&lt;li&gt;Username would be &lt;strong&gt;SU&lt;/strong&gt; and password is &lt;strong&gt;MYPASSWORD123&lt;/strong&gt; as used in the command above to run the container&lt;/li&gt;
&lt;li&gt;Next we can setup our server like the database, tables manually or using any backup file etc&lt;/li&gt;
&lt;li&gt;Now we have our database in place and we want to create an image of this setup so as to when next time someone pulls the image they don't have to manually import the database anymore&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create Custom Docker Image
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, stop the running container using the command
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop MyContainerName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Next we push our changes on to the container so that we can build an image of it
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker commit MyContainerName
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Then copy the image of our specific container from the list using the command
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The newly created image does not have a repository and tag. Execute the following command to tag the image
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker tag &amp;lt;imageID&amp;gt; &amp;lt;docker-hub-username&amp;gt;/&amp;lt;docker-hub-repository-name&amp;gt;:&amp;lt;tag-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example: docker tag a82e969d1395 rajatsrivas/ myownsql:sqlCustomImage&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now our image is built and we can create a container using the image
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 1433:1433 --name sqlCustomImage -d rajatsrivas/ myownsql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you are logged into docker hub on local Docker Desktop this step will be skipped else login using the command prompt
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;docker login -username=rajatsrivas&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enter the password into the next line and finally push the image to the docker hub repository
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;docker push rajatsrivas/myownsql&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;a href="https://hub.docker.com/"&gt;https://hub.docker.com/&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;We should have the image which we pushed to the docker hub&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KDv-YCN---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3t76806r6iqjwyg0ggi2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KDv-YCN---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3t76806r6iqjwyg0ggi2.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Pull and Run our Custom Image 🏃‍♂️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Pull the image on to any machine using the command
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;docker pull rajatsrivas/myownsql:latest&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the container and access the server on the SSMS. The server should have the database which was imported and setup in the earlier steps
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 1433:1433 --name &amp;lt;container-name&amp;gt; -d rajatsrivas/myownsql:latest

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So there it is we have implemented our custom image on top of an official docker image available. &lt;/p&gt;

&lt;p&gt;This is quite a small step in onboarding but one can leverage similar implementations for setting up sandbox environments very quickly and efficiently.&lt;/p&gt;

&lt;p&gt;Hope this was useful. Keep learning keep building&lt;/p&gt;

</description>
      <category>docker</category>
      <category>sqlserver</category>
      <category>programming</category>
      <category>container</category>
    </item>
    <item>
      <title>Implementing your first Build Pipeline for Asp.Net Core using TeamCity Cloud &amp; Docker Hub</title>
      <dc:creator>StackUpDev</dc:creator>
      <pubDate>Wed, 09 Jun 2021 06:07:33 +0000</pubDate>
      <link>https://dev.to/rajat_srivas/implementing-your-first-build-pipeline-for-asp-net-core-using-teamcity-cloud-docker-hub-2hag</link>
      <guid>https://dev.to/rajat_srivas/implementing-your-first-build-pipeline-for-asp-net-core-using-teamcity-cloud-docker-hub-2hag</guid>
      <description>&lt;p&gt;Hey guys, so recently I had this requirement which required me to integrate a build process for .Net Core app using the Github, TeamCity Cloud server and Docker Hub.&lt;/p&gt;

&lt;p&gt;So I researched about it and went on to implement it, and here's in brief what I did. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I used the out of box project created by Visual studio and manually added a docker file in it. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I then went on to create a free trial account on the TeamCity cloud server where I used this docker file to build, publish and then push the docker image to my Docker Hub repository&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally I pulled the docker image on anther machine and there it was our weatherforecast api up and running 🚀 🚀. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since I did could find a proper resource for implementing the same I thought why not give it a go myself. So here I am trying to explain the steps I followed. &lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Account on Team City Cloud Server &lt;a href="https://www.jetbrains.com/teamcity/cloud/"&gt;https://www.jetbrains.com/teamcity/cloud/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Hub account with a repository to publish the image of the asp.net core solution &lt;a href="https://hub.docker.com"&gt;https://hub.docker.com&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Desktop Installed on local to pull and run the deployed image&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sample Dot Net core solution with a docker file. You can refer the one I am using here &lt;a href="https://github.com/rajat-srivas/dotnetcore-teamcity-docker"&gt;https://github.com/rajat-srivas/dotnetcore-teamcity-docker&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I am also assuming you know about docker and are here to understand how to implement this integration &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Project Setup On TeamCity Cloud Server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Login into your team city cloud server&lt;/li&gt;
&lt;li&gt;Click on Project and then create project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aYth55Eq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bu0vh9ngr43jjsnjhzs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aYth55Eq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bu0vh9ngr43jjsnjhzs.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Next we will be connecting our TeamCity server to the GitHub repository so as it can pull up the code every-time there is a new commit&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide the repository URL (&lt;a href="https://github.com/rajat-srivas/dotnetcore-teamcity-docker"&gt;https://github.com/rajat-srivas/dotnetcore-teamcity-docker&lt;/a&gt;), and credentials to access the repository&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ws0jlMhg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tw5b8l8bw0208fp595t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ws0jlMhg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tw5b8l8bw0208fp595t.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Provide the project name and click on Proceed&lt;/li&gt;
&lt;li&gt;Next we need to connect our Docker Hub repository to team city.&lt;/li&gt;
&lt;li&gt;Go the Projects setting page and click on Connections. &lt;/li&gt;
&lt;li&gt;Click on Add Connection and configure Docker Registry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6zVwSbem--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yp1hrw9yu0sd5cozxrok.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6zVwSbem--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yp1hrw9yu0sd5cozxrok.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go back to the build page&lt;/li&gt;
&lt;li&gt;Click on Add Build Feature and select Docker Support. &lt;/li&gt;
&lt;li&gt;Click on Add Registry Connection and use the docker connection created &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JvGwy2RM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8p9pj0lt7vwddpeomg1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JvGwy2RM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8p9pj0lt7vwddpeomg1v.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing the Build Pipeline 🏗
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click on Build Steps to start creating the build pipeline&lt;/li&gt;
&lt;li&gt;For the current solution we need four build steps:&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Net Build&lt;/strong&gt; =&amp;gt; Build the .net solution&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Net Publish&lt;/strong&gt; =&amp;gt; Publishes the .Net Solution in the specified output directory&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Image Build&lt;/strong&gt; =&amp;gt; Reads the specified docker file to create the docker image which contains the content of the folder where .net core solution was published&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Image Push&lt;/strong&gt; =&amp;gt; Pushes the image on Docker hub&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m1XinPmD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6rj43q76zja6ggmgh3mr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m1XinPmD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6rj43q76zja6ggmgh3mr.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Refer the above image to create the builds as mentioned&lt;/li&gt;
&lt;li&gt;Lets now move on the configure the individual steps&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  .Net Build
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--svw8_nZJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e05a4ixmjq93zbw3ovmz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--svw8_nZJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e05a4ixmjq93zbw3ovmz.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Here we just need to set the Command as &lt;strong&gt;Build&lt;/strong&gt; and provide the name of the solution from the repository&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  .Net Publish
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QLmNMOyK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77qnk7ll1w0elmml0a8s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QLmNMOyK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77qnk7ll1w0elmml0a8s.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next we need to specify the folder where the files will be published. This needs to be same as the COPY command source in the docker file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Docker Build
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Here rajatsrivas/testdeploy is the repository name on Docker hub in which my image will be published&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nVUSyDnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zkf2ww483mq7n8fvb3f3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nVUSyDnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zkf2ww483mq7n8fvb3f3.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I'm using the &lt;strong&gt;build.counter&lt;/strong&gt; flag to automatically version the docker image generated so as to keep track of it with the actual build which was triggered&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Docker Push
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c00f4oWr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2i7lmct3jr0w4c6ffxw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c00f4oWr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2i7lmct3jr0w4c6ffxw.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now here the only thing left to do in the build configuration is to push the image which was created to our Docker Hub repo &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Trigger/Run Build Manually
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click on Run at the top right corner to trigger the build. &lt;/li&gt;
&lt;li&gt;Once the build is success, the image should be published in the docker repository specified 😄🍻&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/a0h7sAqON67nO/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/a0h7sAqON67nO/giphy.gif" alt="Great success Gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N4Ic007O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqhad02firsw0kzukv9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N4Ic007O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqhad02firsw0kzukv9p.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the App using the Docker Hub Image
&lt;/h2&gt;

&lt;p&gt;Finally lets try and run the application using the image on our docker repository&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pull the image from docker hub using the command. 
&lt;strong&gt;docker pull rajatsrivas/testdeploy:&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Run the container using the command below
&lt;strong&gt;Docker run -p 80:80 --name  rajatsrivas/testdeploy:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That's it, we have successfully implemented our first build pipeline for a Asp.Net core project using Github, TeamCity and Docker Hub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--44wBjrPz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2c8wpzv9wwzp5vays06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--44wBjrPz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2c8wpzv9wwzp5vays06.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you find these steps useful and you can use it to build upon your own more complex build pipelines. Keep learning keep building...&lt;/p&gt;

</description>
      <category>docker</category>
      <category>aspnetcore</category>
      <category>teamcity</category>
      <category>ci</category>
    </item>
  </channel>
</rss>
