Docker Simple Data Volume Container Example

Posted by {"display_name"=>"greg", "login"=>"greg", "email"=>"greg@udon.org", "url"=>""} on May 06, 2015 · 1 min read

Here's a simple example of Docker container use.

Docker has a tutorial on containers here.

Examples Based on Data Volume Container Name

Create a data volume container:
[shell linenumbers=false]
docker create --name testvol -v /etc/test busybox
[/shell]Run a new container with an interactive shell that references the newly created data volume container. While the shell is open, create some files in the /etc/test directory. Exit and restart the container and you'll see that the files are still there.

[shell linenumbers=false]
docker run --name testsys --volumes-from testvol --rm -i -t busybox sh
[/shell]Backup the files in the data volume to a host directory:

[shell linenumbers=false]
docker run --volumes-from testvol -v $(pwd):/backup busybox tar cvf /backup/backup.tar /etc/test
[/shell]