{"action":"created","issue":{"url":"https://api.github.com/repos/docker-library/postgres/issues/57","labels_url":"https://api.github.com/repos/docker-library/postgres/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/docker-library/postgres/issues/57/comments","events_url":"https://api.github.com/repos/docker-library/postgres/issues/57/events","html_url":"https://github.com/docker-library/postgres/issues/57","id":70263014,"number":57,"title":"Pre-migrated images","user":{"login":"nightscape","id":35170,"avatar_url":"https://avatars.githubusercontent.com/u/35170?v=3","gravatar_id":"","url":"https://api.github.com/users/nightscape","html_url":"https://github.com/nightscape","followers_url":"https://api.github.com/users/nightscape/followers","following_url":"https://api.github.com/users/nightscape/following{/other_user}","gists_url":"https://api.github.com/users/nightscape/gists{/gist_id}","starred_url":"https://api.github.com/users/nightscape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightscape/subscriptions","organizations_url":"https://api.github.com/users/nightscape/orgs","repos_url":"https://api.github.com/users/nightscape/repos","events_url":"https://api.github.com/users/nightscape/events{/privacy}","received_events_url":"https://api.github.com/users/nightscape/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-22T23:39:52Z","updated_at":"2015-04-23T00:00:01Z","closed_at":null,"body":"I wanted to do some pre-migrations as part of the build so that the container can start quicker in tests.\r\nAFAIS this is not currently possible, as `/var/lib/postgresql/data` is specified as a `VOLUME` and during `docker build` all changes to the `VOLUME`s seem to be no-ops. In contrast, first creating a directory and later mounting that same directory as `VOLUME` will copy all files over.\r\n\r\nSee this minimal example, first with the `VOLUME` being mounted at the end\r\n```\r\nStep 0 : FROM debian:wheezy\r\n\r\nStep 1 : RUN mkdir /myvol\r\n\r\nStep 2 : RUN ls -lah /myvol\r\ntotal 8.0K\r\ndrwxr-xr-x  2 root root 4.0K Apr 22 23:27 .\r\ndrwxr-xr-x 29 root root 4.0K Apr 22 23:27 ..\r\n\r\nStep 3 : RUN echo \"hello world\" > /myvol/greeting\r\n\r\nStep 4 : RUN ls -lah /myvol\r\ntotal 12K\r\ndrwxr-xr-x  2 root root 4.0K Apr 22 23:27 .\r\ndrwxr-xr-x 30 root root 4.0K Apr 22 23:27 ..\r\n-rw-r--r--  1 root root   12 Apr 22 23:27 greeting\r\n\r\nStep 5 : VOLUME /myvol\r\n\r\nStep 6 : RUN ls -lah /myvol\r\ntotal 12K\r\ndrwxr-xr-x  2 root root 4.0K Apr 22 23:27 .\r\ndrwxr-xr-x 30 root root 4.0K Apr 22 23:27 ..\r\n-rw-r--r--  1 root root   12 Apr 22 23:27 greeting\r\n```\r\nNow, when you mount the VOLUME already at the beginning:\r\n```\r\nStep 0 : FROM debian:wheezy\r\n\r\nStep 1 : VOLUME /myvol\r\n\r\nStep 2 : RUN ls -lah /myvol\r\ntotal 8.0K\r\ndrwxr-xr-x  2 root root 4.0K Apr 22 23:29 .\r\ndrwxr-xr-x 29 root root 4.0K Apr 22 23:29 ..\r\n\r\nStep 3 : RUN echo \"hello world\" > /myvol/greeting\r\n\r\nStep 4 : RUN ls -lah /myvol\r\ntotal 8.0K\r\ndrwxr-xr-x  2 root root 4.0K Apr 22 23:29 .\r\ndrwxr-xr-x 29 root root 4.0K Apr 22 23:29 ..\r\n```\r\n\r\nDo you see any way around this or another possibility to perform operations on the DB that make it into the image (vs. being executed only on `docker run`)?"},"comment":{"url":"https://api.github.com/repos/docker-library/postgres/issues/comments/95371245","html_url":"https://github.com/docker-library/postgres/issues/57#issuecomment-95371245","issue_url":"https://api.github.com/repos/docker-library/postgres/issues/57","id":95371245,"user":{"login":"tianon","id":161631,"avatar_url":"https://avatars.githubusercontent.com/u/161631?v=3","gravatar_id":"","url":"https://api.github.com/users/tianon","html_url":"https://github.com/tianon","followers_url":"https://api.github.com/users/tianon/followers","following_url":"https://api.github.com/users/tianon/following{/other_user}","gists_url":"https://api.github.com/users/tianon/gists{/gist_id}","starred_url":"https://api.github.com/users/tianon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tianon/subscriptions","organizations_url":"https://api.github.com/users/tianon/orgs","repos_url":"https://api.github.com/users/tianon/repos","events_url":"https://api.github.com/users/tianon/events{/privacy}","received_events_url":"https://api.github.com/users/tianon/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T00:00:01Z","updated_at":"2015-04-23T00:00:01Z","body":"Indeed, I believe @jpetazzo had success with just changing \"PGDATA\" (\"ENV\nPGDATA ...\" or \"-e PGDATA=...\").\n"}}