Writing to docker volume from Dockerfile does not work -


please consider following dockerfile:

from phusion/baseimage volume ["/data"] run touch /data/hello run ls -ls /data 

problem: "/data" directory not contain "hello" file. moreover, other attempts write volume directory (via echo, mv, cp, ...) unsuccessful - directory empty. no error messages shown.

i not find in documentation or on stackoverflow regarding problem.

is well-known or new?

docker version returns:

client version: 1.2.0 client api version: 1.14 go version (client): go1.3.1 git commit (client): fa7b24f os/arch (client): linux/amd64 server version: 1.2.0 server api version: 1.14 go version (server): go1.3.1 git commit (server): fa7b24f 

each step of dockerfile run in it's own container discarded when step done, , volumes discarded when last (in case only) container uses them deleted after it's command finishes. this makes volumes poorly suited use in dockerfiles because loose contents half way through. docker files intended able run anywhere, , if used volumes persisted make harder. on other hand if want this, volume directory on host.

ps: initializing host's data directory best done outside of docker file.

last time needed left step out of docker file because idea of step prepare host run image produced dockerfile. made container docker run , within container ran usual db setup stuff.

docker run -v /var/lib/mysql:/raid/.../mysql ... /usr/bin/mysql_install_db  mysql_secure_installation 

now when container moved new host, data dir can either brought it, or created using same process on host. or if, in example, wanted mysql db other application don't have repeat container creation.

the important idea keep container creation , host setup seperate.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -