{"id":18149277,"url":"https://github.com/jongio/aspnetcorecontainer","last_synced_at":"2025-10-26T01:32:09.202Z","repository":{"id":69183029,"uuid":"94298965","full_name":"jongio/aspnetcorecontainer","owner":"jongio","description":null,"archived":false,"fork":false,"pushed_at":"2017-06-15T01:13:33.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T01:31:53.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jongio.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-14T06:47:54.000Z","updated_at":"2023-08-29T11:06:05.000Z","dependencies_parsed_at":"2023-05-01T16:02:56.256Z","dependency_job_id":null,"html_url":"https://github.com/jongio/aspnetcorecontainer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jongio/aspnetcorecontainer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Faspnetcorecontainer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Faspnetcorecontainer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Faspnetcorecontainer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Faspnetcorecontainer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongio","download_url":"https://codeload.github.com/jongio/aspnetcorecontainer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongio%2Faspnetcorecontainer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281047793,"owners_count":26435124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-01T23:12:30.173Z","updated_at":"2025-10-26T01:32:09.174Z","avatar_url":"https://github.com/jongio.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ASP.NET Core in a Container\n\nHere's a simple example for getting an ASP.NET Core project running in a Docker container.\n\nThis was created to teach the core concepts of Docker.\n\nDefinitions:\n- **Dockerfile**: A manifest file that describes your Docker Image.\n- **Docker Image**: The output of a build of your Dockerfile. Use `docker build` command to create a Docker Image.\n- **Docker Container**: An runtime instance of your Docker Image. Use `docker run` to start a new container instance.\n\n## Pre-reqs\n\n1. Install **.NET Core SDK**: https://www.microsoft.com/net/core#windowscmd\n2. Install **Docker**: https://docs.docker.com/engine/installation/\n- If you are running Windows, [switch to Windows containers](https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers).\n\n## Just Run the Sample\nTo just run the sample: \n1. Clone this repo\n2. Run `build.cmd` in the root.\n\u003e The `build.cmd` file will build the aspnetcore project, copy the output to ./publish folder, build the Docker Image and run the Docker Container.\n\n3. Copy and Paste the outputted IP address into a browser.  \n\n\n\nYou will see \"Hello World\" - an ASP.NET Core site hosted in a container!\n\n## Build the Sample from Scratch\nFollow these instructions to create this sample from scratch.\n\n### 1. Create New Folder\n\nOpen a command prompt and execute the following:\n\n```\nmkdir aspnetcorecontainer\n```\n\n### 2. Create New Core Web Project\n\n```\ndotnet new web\n```\n\n### 3. Restore Dependencies\n```\ndotnet restore\n```\n\n### 4. Run Site\n```\ndotnet run\n```\n\n### 5. Load Site\n\n[http://localhost:5000](http://localhost:5000)\n\n### 6. Create Dockerfile\n\nThis will use the aspnetcore image and copy the files from publish to the /app directory and then configure the dotnet entrypoint to the dll.\n\n```\nFROM microsoft/aspnetcore\nWORKDIR /app\nCOPY ./publish .\nENTRYPOINT [\"dotnet\", \"aspnetcorecontainer.dll\"]\n```\n\n### 7. Build and Publish Site\n```\ndotnet build\ndotnet publish -o ./publish\n```\n\n### 8. Build Container Image\n```\ndocker build -t aspnetcore-image .\n```\n\n### 9. Run Container\n```\ndocker run -d -p 8000:80 --name aspnetcore-container aspnetcore-image\n```\n\n### 10. Get Container IP Address\n```\ndocker inspect -f \"{{ .NetworkSettings.Networks.nat.IPAddress }}\" aspnetcore-container\n```\n\n### 11. Load Site\n\nLoad the IP address returned in the previous step in a browser\n\n### 12. Connect to Container's Powershell Prompt\n\nTo show that the container is running in an isolated space, we are going to see the process count difference between the container and the host machine.\n\n```\ndocker exec -ti aspnetcore-container powershell\n```\n\n### 13. Get Container Process Count\n\nFrom the container's PowerShell prompt:\n\n```\n(Get-Process).Count\n```\n\n### 14. Get Host Machine Process Count\n\nIf you are in cmd, run the following:\n```\npowershell (Get-Process).Count\n```\n\nIf you are in a PS prompt, run the following:\n```\n(Get-Process).Count\n```\n\n\n## Clean Up\n\nExecute the following command to remove the container before you re-run these steps.\n\n```\ndocker rm /aspnetcore-container -f\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongio%2Faspnetcorecontainer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongio%2Faspnetcorecontainer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongio%2Faspnetcorecontainer/lists"}