Vincent Pazeller
Vincent Pazeller

Reputation: 1498

docker-machine deletes files when restarting a vm (virtualbox)

This is maybe a beginner's question, but I am surprised that files are deleted when restarting a vm with docker-machine.

Example:

$ docker-machine create --driver virtualbox test
$ docker-machine ssh test
docker@test$ vi myfile
docker@test$ exit
$ docker-machine stop test
$ docker-machine start test
$ docker-machine ssh test
docker@test$ ls # empty!!!

Can anyone explain? Is this docker-machine related? is this specific to the virtualbox driver? How to avoid this?

Thank you!

Upvotes: 0

Views: 413

Answers (1)

Vincent Pazeller
Vincent Pazeller

Reputation: 1498

From my understanding, files are erased because most partitions are mounted with tmpfs (this can easily be seen with the df command.

This explains why the files disappear after a restart.

In fact, the docker location /var/lib/docker/ is a symlink pointing to /mnt/sda1/var/lib/docker which is a standard partition, meaning that images, container data, volumes and other docker data are peristent and safe.

While I expected to be able to use docker-machine to quickly carry tests and edit Dockerfiles within the created VM, it looks like docker-machine has adopted a production setting (which is good) and only consider docker data. This means that we should work with existing images, not build them inside those VMs

Hope these thoughts will help someone...

Upvotes: 1

Related Questions