{"id":20605232,"url":"https://github.com/arnab-developer/dockerenvvariable","last_synced_at":"2026-01-31T10:33:32.006Z","repository":{"id":68915055,"uuid":"356369013","full_name":"Arnab-Developer/DockerEnvVariable","owner":"Arnab-Developer","description":"Docker environemnt variable","archived":false,"fork":false,"pushed_at":"2021-11-01T15:19:09.000Z","size":664,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-11T05:42:42.709Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/Arnab-Developer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-04-09T18:47:41.000Z","updated_at":"2021-12-05T05:48:16.000Z","dependencies_parsed_at":"2023-02-21T12:00:10.839Z","dependency_job_id":null,"html_url":"https://github.com/Arnab-Developer/DockerEnvVariable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Arnab-Developer/DockerEnvVariable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnab-Developer%2FDockerEnvVariable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnab-Developer%2FDockerEnvVariable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnab-Developer%2FDockerEnvVariable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnab-Developer%2FDockerEnvVariable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arnab-Developer","download_url":"https://codeload.github.com/Arnab-Developer/DockerEnvVariable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arnab-Developer%2FDockerEnvVariable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28938603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T10:18:23.202Z","status":"ssl_error","status_checked_at":"2026-01-31T10:18:22.693Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":[],"created_at":"2024-11-16T09:27:14.118Z","updated_at":"2026-01-31T10:33:31.991Z","avatar_url":"https://github.com/Arnab-Developer.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker environemnt variable\n\nThis is a demo app to show how we can set `ASPNETCORE_ENVIRONMENT` in the\ndocker container at the time of docker container start.\n\nThis sample app is having two different connection strings in `appsettings.json`\nand `appsettings.Development.json`. \n\n```\n\"ConnectionStrings\": {\n  \"ConStr\": \"prd con str\"\n}\n```\n```\n\"ConnectionStrings\": {\n  \"ConStr\": \"dev con str\"\n}\n```\n\nWhen you request the `Home \u003e Index` method then the application logs the value of \nthe connection string.\n\n```c#\nstring conStr = _configuration.GetConnectionString(\"ConStr\");\n_logger.LogInformation(conStr);\n```\n\nWhen we run this app from Visual Studio then we can provide the `ASPNETCORE_ENVIRONMENT` \nvalue in `launchSettings.json` and based on that you can see the output in the log.\n\n```\n\"environmentVariables\": {\n  \"ASPNETCORE_ENVIRONMENT\": \"Development\"\n}\n```\n\nBut when we publish the app and store it in a docker image and run a container\nfrom that image then we can't use `launchSettings.json`. In that case we can \nprovide the value of `ASPNETCORE_ENVIRONMENT` at the time of docker container run.\n\nTo create a docker image\n\n```\ndocker build -t dockerenvvariable:1.0.0 .\n```\n\nTo run a container from the image with `ASPNETCORE_ENVIRONMENT` value\n\n```\ndocker run --name dockerenvvariable-c1 -p 80:80 -e ASPNETCORE_ENVIRONMENT=Development dockerenvvariable:1.0.0\n```\n\nRequest `http:\\\\localhost:80` from a browser and you can see the value `dev con str` in the \nlog file.\n\n## Tech stack\n\nVisual Studio 2019, ASP.NET 5 and docker desktop.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnab-developer%2Fdockerenvvariable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnab-developer%2Fdockerenvvariable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnab-developer%2Fdockerenvvariable/lists"}