Adding a data volume
You can add a data volume to a container using the -v
flag with the docker run
command. You can use the -v
multiple times in a single docker run
to mount multiple data volumes. Let's mount a single volume now in our web application container.
$ sudo docker run -P --name web -v ~/Workspace:/workspace ubuntu
You can then use the --volumes-from
flag to mount the /dbdata
volume in another container.
$ sudo docker run -it --volumes-from workspace -v ~/Workspace ubuntu /bin/bash