{"id":28328459,"url":"https://github.com/nosratifarhad/docker_dotnet6","last_synced_at":"2026-04-13T13:32:25.817Z","repository":{"id":209460927,"uuid":"723750580","full_name":"nosratifarhad/Docker_DotNet6","owner":"nosratifarhad","description":"create docker file and build image ","archived":false,"fork":false,"pushed_at":"2023-11-27T15:32:16.000Z","size":258,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T08:43:40.399Z","etag":null,"topics":["cicd","docker","docker-compose","docker-image","dockerfile","pipeline"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nosratifarhad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-26T16:49:40.000Z","updated_at":"2023-11-27T15:10:41.000Z","dependencies_parsed_at":"2023-11-27T16:50:36.253Z","dependency_job_id":null,"html_url":"https://github.com/nosratifarhad/Docker_DotNet6","commit_stats":null,"previous_names":["nosratifarhad/docker_ci_cd_dotnet6","nosratifarhad/docker_dotnet6"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nosratifarhad/Docker_DotNet6","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FDocker_DotNet6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FDocker_DotNet6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FDocker_DotNet6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FDocker_DotNet6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nosratifarhad","download_url":"https://codeload.github.com/nosratifarhad/Docker_DotNet6/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosratifarhad%2FDocker_DotNet6/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31754926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T13:27:56.013Z","status":"ssl_error","status_checked_at":"2026-04-13T13:21:23.512Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cicd","docker","docker-compose","docker-image","dockerfile","pipeline"],"created_at":"2025-05-26T06:17:05.682Z","updated_at":"2026-04-13T13:32:25.806Z","avatar_url":"https://github.com/nosratifarhad.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# create docker file and build image \n\n### After installing Docker\nAfter installing Docker, you should create a Dockerfile without an extension in the root path of your project.\n\nNow, to build an image from your project, you should enter Docker commands in it. Here is an example:\n\n```docker\nFROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base\nWORKDIR /app\nEXPOSE 80\n\nFROM mcr.microsoft.com/dotnet/sdk:6.0 AS build\nWORKDIR /src\nCOPY [\"/src/TestWebApplication.csproj\",\"API/\"]\nRUN dotnet restore \"API/TestWebApplication.csproj\"\nCOPY . .\nRUN dotnet build \"src/TestWebApplication.csproj\" -c Release -o /app/build\n\nFROM build AS publish \nRUN dotnet build \"src/TestWebApplication.csproj\" -c Release -o /app/publish\n\nFROM base AS final \nWORKDIR /app/build\nCOPY --from=publish /app/publish .\nENTRYPOINT [\"dotnet\",\"TestWebApplication.dll\"]\n```\n\n\n### Part 1. Base image configuration:\n\n```docker\nFROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base\nWORKDIR /app\nEXPOSE 80\n```\nThe first part of the Dockerfile specifies the base image for the final image that will be created. In this case, it is the “mcr.microsoft.com/dotnet/aspnet:6.0” image. The WORKDIR command sets the working directory for the subsequent commands to be executed in. The EXPOSE command specifies the network ports that the container will listen on at runtime.\n\n### Part 2. Build image configuration:\n\n```docker\nFROM mcr.microsoft.com/dotnet/sdk:6.0 AS build\nWORKDIR /src\nCOPY [\"/src/TestWebApplication.csproj\",\"API/\"]\nRUN dotnet restore \"API/TestWebApplication.csproj\"\nCOPY . .\nRUN dotnet build \"src/TestWebApplication.csproj\" -c Release -o /app/build\n```\n\nThe second part of the Dockerfile specifies the build image, which will be used to build the application. It is based on the “mcr.microsoft.com/dotnet/sdk:6.0” image. The WORKDIR command sets the working directory to \"/src\" within the container. The COPY commands copy the necessary files to the container. The RUN command runs the \"dotnet restore\" command to restore the dependencies required by the application. The subsequent COPY . . command copies all the remaining files to the container. Finally, the RUN command builds the application using the \"dotnet build\" command.\n\n### Part 3. Publish image configuration:\n\n```docker\nFROM build AS publish \nRUN dotnet build \"src/TestWebApplication.csproj\" -c Release -o /app/publish\n```\n\nThe third part of the Dockerfile specifies the publish image, which will be used to publish the application. It is based on the previously created build image. The RUN command publishes the application using the \"dotnet publish\" command.\n\n### Part 4. Final image configuration:\n\n```docker\nFROM base AS final \nWORKDIR /app/build\nCOPY --from=publish /app/publish .\nENTRYPOINT [\"dotnet\",\"TestWebApplication.dll\"]\n```\n\nThe final part of the Dockerfile specifies the final image that will be created. It is based on the previously created base image. The WORKDIR command sets the working directory to \"/app\". The COPY command copies the published application from the previous image to the current image. Finally, the ENTRYPOINT command specifies the command that will be run when a container is started from the image, in this case, \"dotnet API.dll\".\n\n\n### Part 4. Now, for the image to be built, you need to execute the following commands in the command line in order.\n\n### Note: Perhaps it might be a bit time-consuming.\n\n\n```cmd\n docker build -t mywebapp -f Dockerfile .\n```\n\n![My Remote Image](https://github.com/nosratifarhad/Docker_CI_CD_DotNet6/blob/main/docs/Annotation1.png)\n\nNow your image has been built.\n\n![My Remote Image](https://github.com/nosratifarhad/Docker_CI_CD_DotNet6/blob/main/docs/Annotation2.png)\n\nnext stap, your must be created container, execute the following command.\n\n```cmd\n\ndocker run -d -p 5000:80 image-name\n```\n```\n\u003e command response must be like this\nPS \u003e docker run -d -p 5000:80 mywebapp\nb89eabf7d169a0805a0017238924e1bee44207c2d7f761b02fe526f620029eb8\nPS \u003e \n```\n\n### Now your container is ready.\n\n![My Remote Image](https://github.com/nosratifarhad/Docker_CI_CD_DotNet6/blob/main/docs/Annotation3.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosratifarhad%2Fdocker_dotnet6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnosratifarhad%2Fdocker_dotnet6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosratifarhad%2Fdocker_dotnet6/lists"}