{"action":"created","issue":{"url":"https://api.github.com/repos/docker/compose/issues/3281","repository_url":"https://api.github.com/repos/docker/compose","labels_url":"https://api.github.com/repos/docker/compose/issues/3281/labels{/name}","comments_url":"https://api.github.com/repos/docker/compose/issues/3281/comments","events_url":"https://api.github.com/repos/docker/compose/issues/3281/events","html_url":"https://github.com/docker/compose/issues/3281","id":146663223,"number":3281,"title":"Unexpected result when using build args with default values","user":{"login":"triccardi-systran","id":1730297,"avatar_url":"https://avatars.githubusercontent.com/u/1730297?v=3","gravatar_id":"","url":"https://api.github.com/users/triccardi-systran","html_url":"https://github.com/triccardi-systran","followers_url":"https://api.github.com/users/triccardi-systran/followers","following_url":"https://api.github.com/users/triccardi-systran/following{/other_user}","gists_url":"https://api.github.com/users/triccardi-systran/gists{/gist_id}","starred_url":"https://api.github.com/users/triccardi-systran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/triccardi-systran/subscriptions","organizations_url":"https://api.github.com/users/triccardi-systran/orgs","repos_url":"https://api.github.com/users/triccardi-systran/repos","events_url":"https://api.github.com/users/triccardi-systran/events{/privacy}","received_events_url":"https://api.github.com/users/triccardi-systran/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/compose/labels/area/config","name":"area/config","color":"c7def8"},{"url":"https://api.github.com/repos/docker/compose/labels/kind/bug","name":"kind/bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-07T15:41:20Z","updated_at":"2016-05-25T13:01:29Z","closed_at":null,"body":"# Scenario:\r\n## Files\r\n`Dockerfile`:\r\n```\r\nFROM ubuntu:14.04\r\n\r\nARG FOO=1\r\nRUN echo \"-${FOO}-\"\r\n\r\nCMD /bin/bash\r\n```\r\n\r\n`docker-compose.yml`:\r\n```\r\nversion: '2'\r\n\r\nservices:\r\n  test:\r\n    build:\r\n      context: .\r\n      args:\r\n        - FOO\r\n```\r\n\r\n## Execution:\r\n```\r\n$ ./docker-compose-1.6.2 --verbose config\r\ncompose.config.config.find: Using configuration files: ./docker-compose.yml\r\nnetworks: {}\r\nservices:\r\n  test:\r\n    build:\r\n      args:\r\n        FOO: None\r\n      context: /home/riccardi/git/ses-docker/test-default-build-arg\r\nversion: '2.0'\r\nvolumes: {}\r\n\r\n```\r\n\r\n```\r\n$ ./docker-compose-1.6.2 --verbose build\r\ncompose.config.config.find: Using configuration files: ./docker-compose.yml\r\ndocker.auth.auth.load_config: File doesn't exist\r\ncompose.cli.command.get_client: docker-compose version 1.6.2, build 4d72027\r\ndocker-py version: 1.7.2\r\nCPython version: 2.7.9\r\nOpenSSL version: OpenSSL 1.0.1e 11 Feb 2013\r\ncompose.cli.command.get_client: Docker base_url: http+docker://localunixsocket\r\ncompose.cli.command.get_client: Docker version: KernelVersion=4.2.0-35-generic, Os=linux, BuildTime=2016-03-10T15:54:52.312835708+00:00, ApiVersion=1.22, Version=1.10.3, GitCommit=20f81dd, Arch=amd64, GoVersion=go1.5.3\r\ncompose.service.build: Building test\r\ncompose.cli.verbose_proxy.proxy_callable: docker build <- (pull=False, stream=True, nocache=False, tag=u'testdefaultbuildarg_test', buildargs={u'FOO': 'None'}, rm=True, forcerm=False, path='/home/riccardi/git/ses-docker/test-default-build-arg', dockerfile=None)\r\ndocker.api.build._set_auth_headers: Looking for auth config\r\ndocker.api.build._set_auth_headers: No auth config in memory - loading from filesystem\r\ndocker.auth.auth.load_config: File doesn't exist\r\ndocker.api.build._set_auth_headers: No auth config found\r\ncompose.cli.verbose_proxy.proxy_callable: docker build -> <generator object _stream_helper at 0x7f56bafb3a50>\r\nStep 1 : FROM ubuntu:14.04\r\n ---> b549a9959a66\r\nStep 2 : ARG FOO=1\r\n ---> Using cache\r\n ---> 4774113d6ec5\r\nStep 3 : RUN echo \"-${FOO}-\"\r\n ---> Running in dabd31837074\r\n-None-\r\n ---> f8a99349af3b\r\nRemoving intermediate container dabd31837074\r\nStep 4 : CMD /bin/bash\r\n ---> Running in 487f5e789c38\r\n ---> 6c484f426fb5\r\nRemoving intermediate container 487f5e789c38\r\nSuccessfully built 6c484f426fb5\r\ncompose.cli.verbose_proxy.proxy_callable: docker close <- ()\r\ncompose.cli.verbose_proxy.proxy_callable: docker close -> None\r\n```\r\n( same result with 1.7.1-rc1 which includes PR #2938 )\r\n\r\n# Issue\r\n## Expected result:\r\nprints `-1-`.\r\n\r\n## Actual result:\r\nprints `-None-`.\r\n\r\n## Details:\r\nCompose has no value for  `FOO` build arg from its environment, so it could either send an empty string to `docker build`, or better: not send this build arg to `docker build`.\r\nThe second one would be great: it would open the possibility to use the default value for the build arg as defined in the `Dockerfile`. ( For now the workaround is to duplicate the default values from `Dockerfile` to `.env`, only works with >=1.7.0).\r\nThe first one would be still better than the current behavior.\r\n\r\nCurrent behavior: no value in Compose environment is represented in python as `None`, then casted to a string `\"None\"`, which is probably always bad.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/docker/compose/issues/comments/221568341","html_url":"https://github.com/docker/compose/issues/3281#issuecomment-221568341","issue_url":"https://api.github.com/repos/docker/compose/issues/3281","id":221568341,"user":{"login":"carletes","id":1711,"avatar_url":"https://avatars.githubusercontent.com/u/1711?v=3","gravatar_id":"","url":"https://api.github.com/users/carletes","html_url":"https://github.com/carletes","followers_url":"https://api.github.com/users/carletes/followers","following_url":"https://api.github.com/users/carletes/following{/other_user}","gists_url":"https://api.github.com/users/carletes/gists{/gist_id}","starred_url":"https://api.github.com/users/carletes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carletes/subscriptions","organizations_url":"https://api.github.com/users/carletes/orgs","repos_url":"https://api.github.com/users/carletes/repos","events_url":"https://api.github.com/users/carletes/events{/privacy}","received_events_url":"https://api.github.com/users/carletes/received_events","type":"User","site_admin":false},"created_at":"2016-05-25T13:01:28Z","updated_at":"2016-05-25T13:01:28Z","body":"> This could be seen as a new feature though. The intermediate step, if needed, would be to just send an empty string instead of the `None` string.\r\n\r\nYep, that would also be helpful for building images behind HTTP proxies.\r\n\r\nI have the following `docker-compose.yml` file:\r\n\r\n```\r\nversion: \"2\"\r\n\r\nservices:\r\n  hello:\r\n    build:\r\n      context: .\r\n      args:\r\n        - http_proxy\r\n    command: sh\r\n```\r\n\r\nand the following `Dockerfile`:\r\n\r\n```\r\nFROM alpine\r\n\r\nRUN set -x && env\r\n```\r\n\r\nWhen I run `docker-compose build hello` *without* the environment variable `http_proxy`, I get `None`:\r\n\r\n```\r\n$ docker-compose build --no-cache hello\r\nBuilding hello\r\nStep 1 : FROM alpine\r\n ---> 13e1761bf172\r\nStep 2 : RUN set -x && env\r\n ---> Running in 0ec8d98bf685\r\nHOSTNAME=27c9668b3d5e\r\nSHLVL=1\r\nHOME=/root\r\nhttp_proxy=None\r\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\r\nPWD=/\r\n+ env\r\n ---> 212f8c97b934\r\nRemoving intermediate container 0ec8d98bf685\r\nSuccessfully built 212f8c97b934\r\n$\r\n```\r\n\r\nWhat I would expect is, in fact, the same behaviour as when `http_proxy` is defined to be empty:\r\n\r\n```\r\n$ env http_proxy= docker-compose build --no-cache hello\r\nBuilding hello\r\nStep 1 : FROM alpine\r\n ---> 13e1761bf172\r\nStep 2 : RUN set -x && env\r\n ---> Running in 6bfec420e409\r\nHOSTNAME=27c9668b3d5e\r\nSHLVL=1\r\nHOME=/root\r\nhttp_proxy=\r\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\r\nPWD=/\r\n+ env\r\n ---> c5bf6c0e0190\r\nRemoving intermediate container 6bfec420e409\r\nSuccessfully built c5bf6c0e0190\r\n(docker-compose)carlos@elouard:~/x$ \r\n```\r\n\r\nIf that were the case, my `docker-compose.yml` and `Dockerfile` would work both at `$WORK`, where I have an HTTP proxy in front of me, and at home, where I do not have such constraint."}}
{"actor":{"display_login":"carletes"}}