Added more info about volumes (#2961)

* Added more info about volumes

Resolves #344

https://docs.docker.com/engine/tutorials/dockervolumes/

* Update dockervolumes.md
This commit is contained in:
Suraj Narwade 2017-04-22 00:27:11 +05:30 committed by Victoria Bialas
parent 9a3c20b74a
commit 82d1d0973e
1 changed files with 23 additions and 3 deletions

View File

@ -37,7 +37,7 @@ Docker therefore *never* automatically deletes volumes when you remove
a container, nor will it "garbage collect" volumes that are no longer
referenced by a container.
### Adding a data volume
### Add a data volume
You can add a data volume to a container using the `-v` flag with the
`docker create` and `docker run` command. You can use the `-v` multiple times
@ -54,7 +54,7 @@ This will create a new volume inside a container at `/webapp`.
> You can also use the `VOLUME` instruction in a `Dockerfile` to add one or
> more new volumes to any container created from that image.
### Locating a volume
### Locate a volume
You can locate the volume on the host by utilizing the `docker inspect` command.
@ -332,7 +332,19 @@ $ docker run --rm --volumes-from dbstore2 -v $(pwd):/backup ubuntu bash -c "cd /
You can use the techniques above to automate backup, migration and
restore testing using your preferred tools.
## Removing volumes
## List all volumes
You can list all existing volumes using `docker volume ls`.
```bash
$ docker volume ls
DRIVER VOLUME NAME
local ec75c47aa8b8c61fdabcf37f89dad44266841b99dc4b48261a4757e70357ec06
local f73e499de345187639cdf3c865d97f241216c2382fe5fa67555c64f258892128
local tmp_data
```
## Remove volumes
A Docker data volume persists after a container is deleted. You can create named
or anonymous volumes. Named volumes have a specific source form outside the
@ -347,6 +359,14 @@ $ docker run --rm -v /foo -v awesome:/bar busybox top
This command creates an anonymous `/foo` volume. When the container is removed,
the Docker Engine removes the `/foo` volume but not the `awesome` volume.
To remove all unused volumes and free up space,
```bash
$ docker volume prune
```
it will remove all unused volumes which are not associated with any container.
## Important tips on using shared volumes
Multiple containers can also share one or more data volumes. However, multiple