{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/12051","labels_url":"https://api.github.com/repos/docker/docker/issues/12051/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/12051/comments","events_url":"https://api.github.com/repos/docker/docker/issues/12051/events","html_url":"https://github.com/docker/docker/issues/12051","id":66111186,"number":12051,"title":"During building dockerfile, build files gets not written if they write after command exits","user":{"login":"kevinsimper","id":1126497,"avatar_url":"https://avatars.githubusercontent.com/u/1126497?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinsimper","html_url":"https://github.com/kevinsimper","followers_url":"https://api.github.com/users/kevinsimper/followers","following_url":"https://api.github.com/users/kevinsimper/following{/other_user}","gists_url":"https://api.github.com/users/kevinsimper/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinsimper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinsimper/subscriptions","organizations_url":"https://api.github.com/users/kevinsimper/orgs","repos_url":"https://api.github.com/users/kevinsimper/repos","events_url":"https://api.github.com/users/kevinsimper/events{/privacy}","received_events_url":"https://api.github.com/users/kevinsimper/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-03T08:54:43Z","updated_at":"2015-04-07T22:19:00Z","closed_at":"2015-04-07T22:18:59Z","body":"I have step in my dockerfile where i concat and uglify my javascript. I am using gulp.js for that and it streaming the files, so it exits before the file is finishes writing, because the bottleneck is the harddrive.\r\n\r\nSo the problem is that because the command exit before the file is finished create, the files does not get commited to the docker image.\r\n\r\nThis does not work, the ls will return a empty folder:\r\n```\r\nFROM node:wheezy\r\n\r\nRUN apt-get update -y && apt-get upgrade -y\r\n\r\nWORKDIR /app\r\n\r\nVOLUME /app\r\n\r\nCOPY . /app\r\n\r\nRUN npm install\r\n\r\nENV NODE_ENV production\r\n\r\nRUN npm run build && ls -alF public/build/\r\n\r\nEXPOSE 9000\r\n\r\nCMD NODE_ENV=production npm start\r\n```\r\n\r\n```\r\nStep 7 : RUN npm run build\r\n ---> Running in ca23524f39da\r\n\r\n> blackbeardapp@1.0.0 build /app\r\n> gulp build\r\n\r\n[08:46:17] Using gulpfile /app/gulpfile.js\r\n[08:46:17] Starting 'browserify'...\r\n[08:46:17] Starting 'browserify-admin'...\r\n[08:46:23] Finished 'browserify' after 5.29 s\r\n[08:46:25] Finished 'browserify-admin' after 7.63 s\r\n[08:46:25] Starting 'build'...\r\n[08:46:25] Finished 'build' after 24 μs\r\n ---> b8a744b92c7b\r\nRemoving intermediate container ca23524f39da\r\nStep 8 : RUN ls -alF public/build/\r\n ---> Running in b7e3db63b293\r\ntotal 12\r\ndrwxr-xr-x 2 root root 4096 Apr  3 08:33 ./\r\ndrwxr-xr-x 6 root root 4096 Mar 29 17:03 ../\r\n-rw-rw-r-- 1 root root    7 Mar 11 21:00 .exists\r\n ---> 3da00e862513\r\n```\r\n\r\nThe build/build is empty, but there should be a `bundle.js` and `admin.js` file.\r\n\r\nBut if i run the build step like this:\r\n\r\n```\r\nRUN npm run build && ls -alF public/build/\r\n```\r\nthe output is this\r\n```\r\nStep 7 : RUN npm run build && ls -alF public/build/\r\n ---> Running in 5167f738d001\r\n\r\n> blackbeardapp@1.0.0 build /app\r\n> gulp build\r\n\r\ntrue\r\n[08:50:07] Using gulpfile /app/gulpfile.js\r\n[08:50:07] Starting 'browserify'...\r\n[08:50:07] Starting 'browserify-admin'...\r\nlevom /app/app/index.js\r\n/app/app/admin/index.js\r\n[08:50:12] Finished 'browserify' after 5.38 s\r\n[08:50:15] Finished 'browserify-admin' after 7.87 s\r\n[08:50:15] Starting 'build'...\r\n[08:50:15] Finished 'build' after 25 μs\r\ntotal 308\r\ndrwxr-xr-x 2 root root   4096 Apr  3 08:50 ./\r\ndrwxr-xr-x 6 root root   4096 Mar 29 17:03 ../\r\n-rw-rw-r-- 1 root root      7 Mar 11 21:00 .exists\r\n-rw-r--r-- 1 root root 142854 Apr  3 08:50 admin.js\r\n-rw-rw-r-- 1 root root 155797 Apr  3 08:50 bundle.js\r\n ---> afca23c83836\r\n```\r\n\r\nSee here is `admin.js` and `bundle.js`.\r\nSo that extra command, lets the files get finished writing and committed right into the dockerfile.\r\n\r\nBut when i then go into the container manually, the files is not there even through seeing it just in the docker buildstep\r\n\r\n```\r\n$ docker run -i -t --rm -P 664fad2625ce /bin/bash\r\nroot@04655c082a27:/app# ls -alF public/build/\r\ntotal 12\r\ndrwxr-xr-x 2 root root 4096 Apr  3 08:33 ./\r\ndrwxr-xr-x 6 root root 4096 Mar 29 17:03 ../\r\n-rw-rw-r-- 1 root root    7 Mar 11 21:00 .exists\r\n```\r\n\r\nThis really weirded me out!"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/90748089","html_url":"https://github.com/docker/docker/issues/12051#issuecomment-90748089","issue_url":"https://api.github.com/repos/docker/docker/issues/12051","id":90748089,"user":{"login":"thaJeztah","id":1804568,"avatar_url":"https://avatars.githubusercontent.com/u/1804568?v=3","gravatar_id":"","url":"https://api.github.com/users/thaJeztah","html_url":"https://github.com/thaJeztah","followers_url":"https://api.github.com/users/thaJeztah/followers","following_url":"https://api.github.com/users/thaJeztah/following{/other_user}","gists_url":"https://api.github.com/users/thaJeztah/gists{/gist_id}","starred_url":"https://api.github.com/users/thaJeztah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaJeztah/subscriptions","organizations_url":"https://api.github.com/users/thaJeztah/orgs","repos_url":"https://api.github.com/users/thaJeztah/repos","events_url":"https://api.github.com/users/thaJeztah/events{/privacy}","received_events_url":"https://api.github.com/users/thaJeztah/received_events","type":"User","site_admin":false},"created_at":"2015-04-07T22:18:59Z","updated_at":"2015-04-07T22:18:59Z","body":"@phemmer is correct here. Volumes are also applied during the build process and a new volume is created for each step; everything performed on the `/app` dir (after the `VOLUME` instruction), will be done in a new volume.\r\n\r\nEither remove the `VOLUME` instruction, or move it to the end of the Dockerfile.\r\n\r\nI'm closing this issue, as it looks like this is not a bug in Docker, but feel free to continue the discussion."}}