Skip to content

Instantly share code, notes, and snippets.

@mikedougherty
Created October 20, 2015 17:40
Show Gist options
  • Select an option

  • Save mikedougherty/a06f4dc534a20767267c to your computer and use it in GitHub Desktop.

Select an option

Save mikedougherty/a06f4dc534a20767267c to your computer and use it in GitHub Desktop.
docker data persists -- reddit
> Disk storage might be volatile
Actually the disk storage of a container is not inherently volatile. Your filesystem in this case still exists in your graph location (default /var/lib/docker, but check your daemon options for a `-g` or `--graph`). Here's a test I just did:
$ docker run --name data-test -it busybox
/ # echo "some text" > /tmp/test.txt
In another shell:
$ docker stop data-test
data-test
Back in the original shell:
/ # %
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f05faab1eaa5 busybox "/bin/sh" 7 minutes ago Exited (137) 1 seconds ago data-test
$ docker start data-test
data-test
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f05faab1eaa5 busybox "/bin/sh" 2 minutes ago Up 21 seconds data-test
$ docker exec data-test cat /tmp/test.txt
some text
So you can see the file and its contents are fine across container start/stops.
Removing a container is when the filesystem is deleted. If you want your data to survive that, that's when you need to involve volumes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment