{"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//project/doc","name":"/project/doc","color":"207de5"},{"url":"https://api.github.com/repos/docker/docker/labels/Proposal","name":"Proposal","color":"009800"},{"url":"https://api.github.com/repos/docker/docker/labels/UX","name":"UX","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":27,"created_at":"2014-11-14T19:55:24Z","updated_at":"2015-02-02T18:24:45Z","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 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"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/72509269","html_url":"https://github.com/docker/docker/pull/9176#issuecomment-72509269","issue_url":"https://api.github.com/repos/docker/docker/issues/9176","id":72509269,"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},"created_at":"2015-02-02T18:24:45Z","updated_at":"2015-02-02T18:24:45Z","body":"@erikh\r\nI think I might be missing your concern around dependency on an *external context* and why is it ok to specify one (through -e or -v flags) when DockerFile has ENV and/or VOLUME primitives defined but not otherwise, as seems to be implied by the discussion snippet you have shared. May be once I understand the concern we can improve this proposal or close it accordingly. Let me explain.\r\n\r\nIf I have understood docker-build philosophy correctly, the ENV or VOLUME primitives have been meant to define constructs, that when embedded in the final image, will keep the image portable across production environments. Accordingly the goal of this proposal is to maintain that philosophy and yet introduce a mechanism to define constructs that are needed for just build environments like http_proxy, authentication tokens etc. Based on this understanding, I have a few observations/concerns on the discussion snippet you have shared:\r\n1. Overriding ENV and VOLUME with args for -e or -v option runs a risk of not leaving the final image portable for production environments. (https://github.com/docker/docker/issues/4962#issuecomment-39383378)\r\n2. There might not always be good defaults for ENV and/or VOLUME primitives. For example, what are good defaults for things like http_proxy, auth tokens that can be embedded in a DockerFile and hence the final image?\r\n3. Also this introduces a coupling/dependency between the DockerFile author and the builder (who might not always be the same). For instance, can we assume that a DockerFile author always knows all ENV vars to define and set to default that will work for different build environments?\r\n\r\nIf the above observations resonate with you as well, I fail to see how the discussion snippet offers an alternate solution to this proposal. Kindly correct me if I am missing something basic.\r\n\r\nOne way I could think of to enhance this proposal is to introduce new primitives to dockerfile like BUILDTIME-ENV, BUILDTIME-VOLUME  etc which introduce variables that live only for build time but not in final image and then then let -e or -v flags to take effect based on the discussion snippet. But this at most only addresses my concern '1' above."}}