{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/9176","labels_url":"https://api.github.com/repos/docker/docker/issues/9176/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/9176/comments","events_url":"https://api.github.com/repos/docker/docker/issues/9176/events","html_url":"https://github.com/docker/docker/pull/9176","id":48832781,"number":9176,"title":"Proposal: Add support for build-time environment variables to the 'build' API","user":{"login":"mapuri","id":9538438,"avatar_url":"https://avatars.githubusercontent.com/u/9538438?v=3","gravatar_id":"","url":"https://api.github.com/users/mapuri","html_url":"https://github.com/mapuri","followers_url":"https://api.github.com/users/mapuri/followers","following_url":"https://api.github.com/users/mapuri/following{/other_user}","gists_url":"https://api.github.com/users/mapuri/gists{/gist_id}","starred_url":"https://api.github.com/users/mapuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapuri/subscriptions","organizations_url":"https://api.github.com/users/mapuri/orgs","repos_url":"https://api.github.com/users/mapuri/repos","events_url":"https://api.github.com/users/mapuri/events{/privacy}","received_events_url":"https://api.github.com/users/mapuri/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/status/1-needs-design-review","name":"status/1-needs-design-review","color":"fef2c0"},{"url":"https://api.github.com/repos/docker/docker/labels/status/needs-attention","name":"status/needs-attention","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"milestone":null,"comments":337,"created_at":"2014-11-14T19:55:24Z","updated_at":"2015-06-26T00:17:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/9176","html_url":"https://github.com/docker/docker/pull/9176","diff_url":"https://github.com/docker/docker/pull/9176.diff","patch_url":"https://github.com/docker/docker/pull/9176.patch"},"body":"A build-time environment variable is passed to the builder (as part of build API) and made available to the Dockerfile primitives for use in variable expansion and setting up the environment for the RUN primitive (without modifying the Dockerfile and persisting them as environment in the final image). \r\n\r\nFollowing simple example illustrates the feature:\r\n```\r\ndocker build --build-env usr=foo --build-env http_proxy=\"my.proxy.url\" <<EOF\r\nFrom busybox\r\nUSER ${usr:-bar}\r\nRUN git clone <my.private.repo.behind.a.proxy>\r\nEOF\r\n```\r\n\r\nSome of the use cases this PR enables are listed below (captured from comments in the PR's thread).\r\n\r\n[*Edit: 05/22/2015*] ~~A build-time environment variable gets used only while processing the 'RUN' primitive of a DockerFile. Such a variable is only accessible during 'RUN' and is 'not' persisted with the intermediate and final docker images, thereby addressing the portability concerns of the images generated with 'build'.~~\r\n\r\nThis addresses issue #4962 \r\n\r\n+++++++++\r\n*Edit: 05/21/2015*\r\n\r\nThis PR discussion thread has grown, bringing out use cases that this PR serves and doesn't serves well. Below I consolidate a list of those use cases that have emerged from the comments for ease of reference.\r\n\r\n**There are two broad usecases that this feature enables:**\r\n\r\n- passing build environment specific variables without modifying the Dockerfile or persisting them in the final image. A common usecase is the proxy url (http_proxy, https_proxy...) but this can be any other environment variable as well.\r\n - *related comments*:\r\n  https://github.com/docker/docker/pull/9176#issuecomment-72072046\r\n  https://github.com/docker/docker/pull/9176#issuecomment-104386863  \r\n  \r\n- parametrize builds.\r\n  - *related comments*:\r\n  https://github.com/docker/docker/pull/9176#issuecomment-99269827\r\n  https://github.com/docker/docker/pull/9176#issuecomment-75432026\r\n  https://github.com/docker/docker/issues/9731#issuecomment-77370381\r\n\r\n**The following use-case is not served well by this feature and hence not recommended to be used such:**\r\n\r\n- passing secrets with caching turned on:\r\n  - *related comments*:\r\n  https://github.com/docker/docker/pull/9176#issuecomment-101876406\r\n  https://github.com/docker/docker/pull/9176#issuecomment-99542089\r\n\r\n**Following use-cases might still be suitable with caching turned off:** \r\n  https://github.com/docker/docker/pull/9176#issuecomment-88278968\r\n  https://github.com/docker/docker/pull/9176#issuecomment-88377527\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/115437937","html_url":"https://github.com/docker/docker/pull/9176#issuecomment-115437937","issue_url":"https://api.github.com/repos/docker/docker/issues/9176","id":115437937,"user":{"login":"staab","id":2494842,"avatar_url":"https://avatars.githubusercontent.com/u/2494842?v=3","gravatar_id":"","url":"https://api.github.com/users/staab","html_url":"https://github.com/staab","followers_url":"https://api.github.com/users/staab/followers","following_url":"https://api.github.com/users/staab/following{/other_user}","gists_url":"https://api.github.com/users/staab/gists{/gist_id}","starred_url":"https://api.github.com/users/staab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/staab/subscriptions","organizations_url":"https://api.github.com/users/staab/orgs","repos_url":"https://api.github.com/users/staab/repos","events_url":"https://api.github.com/users/staab/events{/privacy}","received_events_url":"https://api.github.com/users/staab/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T00:17:02Z","updated_at":"2015-06-26T00:17:02Z","body":"Just to add some substantiation to the claims that new users (I think I count - I started with Docker two days ago) are going to shoot themselves in the foot with this feature, I found this thread, very hopeful that build-time environment variables were incoming, but the discussion here helped me realize that build time is not the time to parameterize my containers (as far as my use case is concerned). Things like secrets, service urls, and tool features/modes were definitely things I intended to insert. All of these fit much better into runtime, so I can share images between production, dev, and demo. So thanks all of you for hashing this out! \r\n\r\nMy two cents on this issue, though I don't know the particulars well (obviously), is that opinionated frameworks are good. I think the Docker maintainers would agree, given their reluctance to make potentially dangerous/insecure design decisions."}}