{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/3199","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/3199/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/3199/comments","events_url":"https://api.github.com/repos/docker/docker/issues/3199/events","html_url":"https://github.com/docker/docker/issues/3199","id":24216908,"number":3199,"title":"`docker build -no-cache` does not consistently invalidate the cache for subsequent builds","user":{"login":"vreon","id":52548,"avatar_url":"https://avatars.githubusercontent.com/u/52548?v=3","gravatar_id":"","url":"https://api.github.com/users/vreon","html_url":"https://github.com/vreon","followers_url":"https://api.github.com/users/vreon/followers","following_url":"https://api.github.com/users/vreon/following{/other_user}","gists_url":"https://api.github.com/users/vreon/gists{/gist_id}","starred_url":"https://api.github.com/users/vreon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vreon/subscriptions","organizations_url":"https://api.github.com/users/vreon/orgs","repos_url":"https://api.github.com/users/vreon/repos","events_url":"https://api.github.com/users/vreon/events{/privacy}","received_events_url":"https://api.github.com/users/vreon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2013-12-12T23:27:31Z","updated_at":"2017-01-31T16:01:29Z","closed_at":"2013-12-12T23:29:23Z","body":"In this example, `docker build -no-cache` appears to invalidate the cache for subsequent builds:\n\n``` console\n$ cat Dockerfile\nFROM ubuntu:12.10\nRUN date > builddate\n$ docker build -t vreon/cachetest .\nUploading context 10240 bytes\nStep 1 : FROM ubuntu:12.10\n ---> b750fe79269d\nStep 2 : RUN date > builddate\n ---> Running in cb5a9c443588\n ---> 9259bb0663e7\nSuccessfully built 9259bb0663e7\n$ docker build -no-cache -t vreon/cachetest .\nUploading context 10240 bytes\nStep 1 : FROM ubuntu:12.10\n ---> b750fe79269d\nStep 2 : RUN date > builddate\n ---> Running in 411ace38ef1f\n ---> 237318dc283c\nSuccessfully built 237318dc283c\n$ docker build -t vreon/cachetest .\nUploading context 10240 bytes\nStep 1 : FROM ubuntu:12.10\n ---> b750fe79269d\nStep 2 : RUN date > builddate\n ---> Using cache\n ---> 237318dc283c\nSuccessfully built 237318dc283c\n```\n\n```\ntl;dr: 9259bb0663e7, 237318dc283c, 237318dc283c\n```\n\n\"Awesome,\" you'd think, \"`-no-cache` is a nice way to force a full rebuild and account for the occasional RUN that isn't actually deterministic.\"\n\nBut then you try it with a slightly different RUN instruction:\n\n``` console\n$ cat Dockerfile\nFROM ubuntu:12.10\nRUN echo `date` > builddate\n$ docker build -t vreon/cachetest .\nUploading context 10240 bytes\nStep 1 : FROM ubuntu:12.10\n ---> b750fe79269d\nStep 2 : RUN echo `date` > builddate\n ---> Running in 0c320266f660\n ---> 1c732f0b8836\nSuccessfully built 1c732f0b8836\n$ docker build -no-cache -t vreon/cachetest .\nUploading context 10240 bytes\nStep 1 : FROM ubuntu:12.10\n ---> b750fe79269d\nStep 2 : RUN echo `date` > builddate\n ---> Running in 67d2a2ae033a\n ---> f59e6459f768\nSuccessfully built f59e6459f768\n$ docker build -t vreon/cachetest .\nUploading context 10240 bytes\nStep 1 : FROM ubuntu:12.10\n ---> b750fe79269d\nStep 2 : RUN echo `date` > builddate\n ---> Using cache\n ---> 1c732f0b8836\nSuccessfully built 1c732f0b8836\n```\n\n```\ntl;dr: 1c732f0b8836, f59e6459f768, 1c732f0b8836\n```\n\nSo now `-no-cache` appears to _not_ invalidate the cache -- the third build used the images generated by the first. Essentially, the first time you use `-no-cache`, you have to keep using `-no-cache` on all subsequent builds, or you risk reusing a layer you thought invalidated.\n\n``` console\n$ docker version\nClient version: 0.7.1\nGo version (client): go1.2\nGit commit (client): e39d35d\nServer version: 0.7.1\nGit commit (server): e39d35d\nGo version (server): go1.2\nLast stable version: 0.7.1\n$ docker info\nContainers: 49\nImages: 50\nDriver: aufs\n Root Dir: /mnt/archive/docker/aufs\n Dirs: 151\nWARNING: No swap limit support\n```\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/276405240","html_url":"https://github.com/docker/docker/issues/3199#issuecomment-276405240","issue_url":"https://api.github.com/repos/docker/docker/issues/3199","id":276405240,"user":{"login":"vreon","id":52548,"avatar_url":"https://avatars.githubusercontent.com/u/52548?v=3","gravatar_id":"","url":"https://api.github.com/users/vreon","html_url":"https://github.com/vreon","followers_url":"https://api.github.com/users/vreon/followers","following_url":"https://api.github.com/users/vreon/following{/other_user}","gists_url":"https://api.github.com/users/vreon/gists{/gist_id}","starred_url":"https://api.github.com/users/vreon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vreon/subscriptions","organizations_url":"https://api.github.com/users/vreon/orgs","repos_url":"https://api.github.com/users/vreon/repos","events_url":"https://api.github.com/users/vreon/events{/privacy}","received_events_url":"https://api.github.com/users/vreon/received_events","type":"User","site_admin":false},"created_at":"2017-01-31T16:01:29Z","updated_at":"2017-01-31T16:01:29Z","body":"@samistart, Docker used single dashes for long options in 2013.\r\n\r\nI haven't used `--no-cache` since this issue was closed, but I'm pleased to note that the bug is no longer present in modern versions of Docker."}}
{"actor":{"display_login":"vreon"}}