{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleContainerTools/kaniko/issues/334","repository_url":"https://api.github.com/repos/GoogleContainerTools/kaniko","labels_url":"https://api.github.com/repos/GoogleContainerTools/kaniko/issues/334/labels{/name}","comments_url":"https://api.github.com/repos/GoogleContainerTools/kaniko/issues/334/comments","events_url":"https://api.github.com/repos/GoogleContainerTools/kaniko/issues/334/events","html_url":"https://github.com/GoogleContainerTools/kaniko/pull/334","id":356683775,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyODc4NzI0","number":334,"title":"Stop adding volume directories to the snapshot","user":{"login":"peter-evans","id":18365890,"node_id":"MDQ6VXNlcjE4MzY1ODkw","avatar_url":"https://avatars0.githubusercontent.com/u/18365890?v=4","gravatar_id":"","url":"https://api.github.com/users/peter-evans","html_url":"https://github.com/peter-evans","followers_url":"https://api.github.com/users/peter-evans/followers","following_url":"https://api.github.com/users/peter-evans/following{/other_user}","gists_url":"https://api.github.com/users/peter-evans/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-evans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-evans/subscriptions","organizations_url":"https://api.github.com/users/peter-evans/orgs","repos_url":"https://api.github.com/users/peter-evans/repos","events_url":"https://api.github.com/users/peter-evans/events{/privacy}","received_events_url":"https://api.github.com/users/peter-evans/received_events","type":"User","site_admin":false},"labels":[{"id":1034302868,"node_id":"MDU6TGFiZWwxMDM0MzAyODY4","url":"https://api.github.com/repos/GoogleContainerTools/kaniko/labels/needs-ok-to-test","name":"needs-ok-to-test","color":"ededed","default":false},{"id":1037240090,"node_id":"MDU6TGFiZWwxMDM3MjQwMDkw","url":"https://api.github.com/repos/GoogleContainerTools/kaniko/labels/size/XS","name":"size/XS","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-09-04T07:25:46Z","updated_at":"2018-09-12T04:35:55Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/GoogleContainerTools/kaniko/pulls/334","html_url":"https://github.com/GoogleContainerTools/kaniko/pull/334","diff_url":"https://github.com/GoogleContainerTools/kaniko/pull/334.diff","patch_url":"https://github.com/GoogleContainerTools/kaniko/pull/334.patch"},"body":"This is an attempt to fix https://github.com/GoogleContainerTools/kaniko/issues/313 by not adding the created directories to the `VOLUME` command snapshot. Adding to the snapshot creates a layer in the container that doesn't exist when building with Docker."},"comment":{"url":"https://api.github.com/repos/GoogleContainerTools/kaniko/issues/comments/420509190","html_url":"https://github.com/GoogleContainerTools/kaniko/pull/334#issuecomment-420509190","issue_url":"https://api.github.com/repos/GoogleContainerTools/kaniko/issues/334","id":420509190,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDUwOTE5MA==","user":{"login":"peter-evans","id":18365890,"node_id":"MDQ6VXNlcjE4MzY1ODkw","avatar_url":"https://avatars0.githubusercontent.com/u/18365890?v=4","gravatar_id":"","url":"https://api.github.com/users/peter-evans","html_url":"https://github.com/peter-evans","followers_url":"https://api.github.com/users/peter-evans/followers","following_url":"https://api.github.com/users/peter-evans/following{/other_user}","gists_url":"https://api.github.com/users/peter-evans/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-evans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-evans/subscriptions","organizations_url":"https://api.github.com/users/peter-evans/orgs","repos_url":"https://api.github.com/users/peter-evans/repos","events_url":"https://api.github.com/users/peter-evans/events{/privacy}","received_events_url":"https://api.github.com/users/peter-evans/received_events","type":"User","site_admin":false},"created_at":"2018-09-12T04:35:55Z","updated_at":"2018-09-12T04:35:55Z","author_association":"NONE","body":"I can't find any official documentation to back this up but this is my theory of how Docker treats the `VOLUME` directive based on some testing.\r\n\r\nDockerfile directives seem to be split into two categories:\r\n1. Directives that trigger a layer to be written to the image __if the file-system has changes__.\r\n   e.g. `FROM`, `COPY`, `ADD`, `RUN`, etc.\r\n2. Directives that do not trigger a layer to be written to the image __regardless of whether the file-system has changes__.\r\n   e.g. `ARG`, `ENV`, `ENTRYPOINT`, `EXPOSE`, etc.\r\n\r\nThe `VOLUME` directive is in the second category. It never triggers a layer to be written, even if it causes file-system changes. If directives in the second category make file-system changes since the last layer written to the image they are carried over until a directive in the first category is met. In actuality, `VOLUME` seems to be the only second category directive that _can_ make file-system changes. So in that regard it could be considered an exception. If the end of the Dockerfile is reached and there are still file-system changes carried over from `VOLUME` directives they are discarded—no final layer is written.\r\n\r\nBelow is an example to demonstrate. The the `VOLUME` directive changes are combined with file-system changes at the next `RUN` directive. Notice how that even though `RUN echo \"foo2\"` makes no file-system changes it still triggers a layer. This is because the file-system changes of the previous `VOLUME` directive have been carried over. If we removed `VOLUME /volume1` and rebuilt the image `RUN echo \"foo2\"` would not trigger a new layer to be written. Also notice that the final `VOLUME /volume5` file-system changes are discarded and no layer is added.\r\n\r\n__Dockerfile__:\r\n```dockerfile\r\nFROM gcr.io/google-appengine/debian9@sha256:1d6a9a6d106bd795098f60f4abb7083626354fa6735e81743c7f8cfca11259f0\r\nVOLUME /volume1\r\nRUN mkdir /foo1\r\nVOLUME /volume2\r\nVOLUME /volume3\r\nRUN echo \"foo2\"\r\nVOLUME /volume4\r\nRUN mkdir /foo3\r\nVOLUME /volume5\r\n```\r\n```\r\n$ container-diff analyze daemon://kanikotest --type layer\r\n-----FileLayer-----\r\n\r\nAnalysis for kanikotest Layer 0:\r\n<Truncated for brevity>\r\n\r\nAnalysis for kanikotest Layer 1:\r\nFILE            SIZE\r\n/foo1           0\r\n/volume1        0\r\n\r\nAnalysis for kanikotest Layer 2:\r\nFILE            SIZE\r\n/volume2        0\r\n/volume3        0\r\n\r\nAnalysis for kanikotest Layer 3:\r\nFILE            SIZE\r\n/foo3           0\r\n/volume4        0\r\n```"}}
{"actor":{"display_login":"peter-evans"}}