Merge pull request #15929 from usha-mandya/volumes-patch

Update Volumes, fix navigation
This commit is contained in:
Sebastiaan van Stijn 2022-10-27 18:43:06 -04:00 committed by GitHub
commit c4432a8df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 111 deletions

View File

@ -6,7 +6,7 @@ long: |-
the container, `docker export` will export the contents of the *underlying* the container, `docker export` will export the contents of the *underlying*
directory, not the contents of the volume. directory, not the contents of the volume.
Refer to [Backup, restore, or migrate data volumes](https://docs.docker.com/storage/volumes/#backup-restore-or-migrate-data-volumes) Refer to [Back up, restore, or migrate data volumes](https://docs.docker.com/storage/volumes/#back-up-restore-or-migrate-data-volumes)
in the user guide for examples on exporting data in a volume. in the user guide for examples on exporting data in a volume.
usage: docker export [OPTIONS] CONTAINER usage: docker export [OPTIONS] CONTAINER
pname: docker pname: docker

View File

@ -191,6 +191,28 @@ guides:
title: Configure and run Docker title: Configure and run Docker
- path: /config/daemon/systemd/ - path: /config/daemon/systemd/
title: Control Docker with systemd title: Control Docker with systemd
- path: /config/daemon/ipv6/
title: Configure the daemon for IPv6
- path: /network/iptables/
title: Docker and iptables
- sectiontitle: Store data within containers
section:
- path: /storage/storagedriver/
title: About storage drivers
- path: /storage/storagedriver/select-storage-driver/
title: Select a storage driver
- path: /storage/storagedriver/aufs-driver/
title: Use the AUFS storage driver
- path: /storage/storagedriver/btrfs-driver/
title: Use the Btrfs storage driver
- path: /storage/storagedriver/device-mapper-driver/
title: Use the Device mapper storage driver
- path: /storage/storagedriver/overlayfs-driver/
title: Use the OverlayFS storage driver
- path: /storage/storagedriver/zfs-driver/
title: Use the ZFS storage driver
- path: /storage/storagedriver/vfs-driver/
title: Use the VFS storage driver
- path: /config/daemon/prometheus/ - path: /config/daemon/prometheus/
title: Collect metrics with Prometheus title: Collect metrics with Prometheus
- sectiontitle: Configure containers - sectiontitle: Configure containers
@ -319,6 +341,10 @@ guides:
section: section:
- path: /network/ - path: /network/
title: Networking overview title: Networking overview
- path: /config/containers/container-networking/
title: Container networking
- path: /network/proxy/
title: Configure Docker to use a proxy server
- path: /network/bridge/ - path: /network/bridge/
title: Use bridge networks title: Use bridge networks
- path: /network/overlay/ - path: /network/overlay/
@ -341,24 +367,14 @@ guides:
title: Overlay networking tutorial title: Overlay networking tutorial
- path: /network/network-tutorial-macvlan/ - path: /network/network-tutorial-macvlan/
title: Macvlan network tutorial title: Macvlan network tutorial
- sectiontitle: Configure the daemon and containers
section:
- path: /config/daemon/ipv6/
title: Configure the daemon for IPv6
- path: /network/iptables/
title: Docker and iptables
- path: /config/containers/container-networking/
title: Container networking
- path: /network/proxy/
title: Configure Docker to use a proxy server
- sectiontitle: Legacy networking content - sectiontitle: Legacy networking content
section: section:
- path: /network/links/ - path: /network/links/
title: (Legacy) Container links title: (Legacy) Container links
- sectiontitle: Manage application data - sectiontitle: Configure storage
section: section:
- path: /storage/ - path: /storage/
title: Storage overview title: Overview
- path: /storage/volumes/ - path: /storage/volumes/
title: Volumes title: Volumes
- path: /storage/bind-mounts/ - path: /storage/bind-mounts/
@ -366,25 +382,7 @@ guides:
- path: /storage/tmpfs/ - path: /storage/tmpfs/
title: tmpfs mounts title: tmpfs mounts
- path: /storage/troubleshooting_volume_errors/ - path: /storage/troubleshooting_volume_errors/
title: Troubleshoot volume problems title: Troubleshoot
- sectiontitle: Store data within containers
section:
- path: /storage/storagedriver/
title: About storage drivers
- path: /storage/storagedriver/select-storage-driver/
title: Select a storage driver
- path: /storage/storagedriver/aufs-driver/
title: Use the AUFS storage driver
- path: /storage/storagedriver/btrfs-driver/
title: Use the Btrfs storage driver
- path: /storage/storagedriver/device-mapper-driver/
title: Use the Device mapper storage driver
- path: /storage/storagedriver/overlayfs-driver/
title: Use the OverlayFS storage driver
- path: /storage/storagedriver/zfs-driver/
title: Use the ZFS storage driver
- path: /storage/storagedriver/vfs-driver/
title: Use the VFS storage driver
- path: /get-started/resources/ - path: /get-started/resources/
title: "Educational resources" title: "Educational resources"

View File

@ -22,7 +22,7 @@ computer, for example.
Also note that filesystem changes in volume that are attached to the Also note that filesystem changes in volume that are attached to the
container are not included in the image, and must be backed up separately. container are not included in the image, and must be backed up separately.
If you used a [named volume](../storage/index.md#more-details-about-mount-types) to store container data, such as databases, refer to the [backup, restore, or migrate data volumes](../storage/volumes.md#backup-restore-or-migrate-data-volumes) page in the storage section. If you used a [named volume](../storage/index.md#more-details-about-mount-types) to store container data, such as databases, refer to the [back up, restore, or migrate data volumes](../storage/volumes.md#back-up-restore-or-migrate-data-volumes) page in the storage section.
2. Use [`docker push`](../engine/reference/commandline/push.md) to push any 2. Use [`docker push`](../engine/reference/commandline/push.md) to push any
images you have built locally and want to keep to the [Docker Hub registry](../docker-hub/index.md). images you have built locally and want to keep to the [Docker Hub registry](../docker-hub/index.md).
@ -47,4 +47,4 @@ and [install a different version](release-notes.md) or reset Docker Desktop to f
2. Re-create your containers if needed, using [`docker run`](../engine/reference/commandline/load.md), 2. Re-create your containers if needed, using [`docker run`](../engine/reference/commandline/load.md),
or [Docker Compose](../compose/index.md). or [Docker Compose](../compose/index.md).
Refer to the [backup, restore, or migrate data volumes](../storage/volumes.md#backup-restore-or-migrate-data-volumes) page in the storage section to restore volume data. Refer to the [backup, restore, or migrate data volumes](../storage/volumes.md#back-up-restore-or-migrate-data-volumes) page in the storage section to restore volume data.

View File

@ -47,7 +47,7 @@ This page contains release notes for older versions of Docker Desktop for Mac.
- Re-enable raw as the default disk format for users running macOS 10.13.4 and higher. Note this change only takes effect after a "reset to factory defaults" or "remove all data" (from the Whale menu -> Preferences -> Reset). Related to [docker/for-mac#2625](https://github.com/docker/for-mac/issues/2625) - Re-enable raw as the default disk format for users running macOS 10.13.4 and higher. Note this change only takes effect after a "reset to factory defaults" or "remove all data" (from the Whale menu -> Preferences -> Reset). Related to [docker/for-mac#2625](https://github.com/docker/for-mac/issues/2625)
* Bug fixes and minor changes * Bug fixes and minor changes
- AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset disk image (in Preferences > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [backup volumes](../../storage/volumes.md#backup-restore-or-migrate-data-volumes) - AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset disk image (in Preferences > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [back up volumes](../../storage/volumes.md#back-up-restore-or-migrate-data-volumes)
- OS X El Captain 10.11 is deprecated in Docker Desktop. You will not be able to install updates after Docker Desktop 18.06.x. We recommend upgrading to the latest version of macOS. - OS X El Captain 10.11 is deprecated in Docker Desktop. You will not be able to install updates after Docker Desktop 18.06.x. We recommend upgrading to the latest version of macOS.
- Fix bug which would cause VM logs to be written to RAM rather than disk in some cases, and the VM to hang. See [docker/for-mac#2984](https://github.com/docker/for-mac/issues/2984) - Fix bug which would cause VM logs to be written to RAM rather than disk in some cases, and the VM to hang. See [docker/for-mac#2984](https://github.com/docker/for-mac/issues/2984)
- Fix network connection leak triggered by haproxy TCP health-checks [docker/for-mac#1132](https://github.com/docker/for-mac/issues/1132) - Fix network connection leak triggered by haproxy TCP health-checks [docker/for-mac#1132](https://github.com/docker/for-mac/issues/1132)

View File

@ -67,7 +67,7 @@ This page contains release notes for older versions of Docker Desktop for Window
- Kubernetes Support. You can now run a single-node Kubernetes cluster from the "Kubernetes" Pane in Docker for Windows settings and use kubectl commands as well as Docker commands. See [the Kubernetes section](../kubernetes.md) - Kubernetes Support. You can now run a single-node Kubernetes cluster from the "Kubernetes" Pane in Docker for Windows settings and use kubectl commands as well as Docker commands. See [the Kubernetes section](../kubernetes.md)
* Bug fixes and minor changes * Bug fixes and minor changes
- AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset the disk image (in Settings > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [backup volumes](../../storage/volumes.md#backup-restore-or-migrate-data-volumes) - AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset the disk image (in Settings > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [backup volumes](../../storage/volumes.md#back-up-restore-or-migrate-data-volumes)
- Fix bug which would in some cases cause virtual machine logs to be written to RAM rather than disk, and the virtual machine to hang. - Fix bug which would in some cases cause virtual machine logs to be written to RAM rather than disk, and the virtual machine to hang.
- Fix security issue with named pipe connection to docker service. - Fix security issue with named pipe connection to docker service.
- Fix VPNKit memory leak. Fixes [docker/for-win#2087](https://github.com/docker/for-win/issues/2087), [moby/vpnkit#371](https://github.com/moby/vpnkit/issues/371) - Fix VPNKit memory leak. Fixes [docker/for-win#2087](https://github.com/docker/for-win/issues/2087), [moby/vpnkit#371](https://github.com/moby/vpnkit/issues/371)

View File

@ -950,7 +950,7 @@ This release contains a Kubernetes upgrade. Note that your local Kubernetes clus
- Add an experimental SOCKS server to allow access to container networks, see [docker/for-mac#2670](https://github.com/docker/for-mac/issues/2670#issuecomment-372365274). Also see [docker/for-mac#2721](https://github.com/docker/for-mac/issues/2721) - Add an experimental SOCKS server to allow access to container networks, see [docker/for-mac#2670](https://github.com/docker/for-mac/issues/2670#issuecomment-372365274). Also see [docker/for-mac#2721](https://github.com/docker/for-mac/issues/2721)
* Bug fixes and minor changes * Bug fixes and minor changes
- AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset disk image (in Preferences > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [backup volumes](../../storage/volumes.md#backup-restore-or-migrate-data-volumes) - AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset disk image (in Preferences > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [back up volumes](../../storage/volumes.md#back-up-restore-or-migrate-data-volumes)
- Fix startup issue with AUFS [docker/for-mac#2804](https://github.com/docker/for-mac/issues/2804) - Fix startup issue with AUFS [docker/for-mac#2804](https://github.com/docker/for-mac/issues/2804)
- Fix status bug which could prevent the Kubernetes cluster from starting. Fixes [docker/for-mac#2990](https://github.com/docker/for-mac/issues/2990) - Fix status bug which could prevent the Kubernetes cluster from starting. Fixes [docker/for-mac#2990](https://github.com/docker/for-mac/issues/2990)
- Fix bug which would cause virtual machine logs to be written to RAM rather than disk in some cases, and the virtual machine to hang. See [docker/for-mac#2984](https://github.com/docker/for-mac/issues/2984) - Fix bug which would cause virtual machine logs to be written to RAM rather than disk in some cases, and the virtual machine to hang. See [docker/for-mac#2984](https://github.com/docker/for-mac/issues/2984)

View File

@ -1162,7 +1162,7 @@ This release contains a Kubernetes upgrade. Note that your local Kubernetes clus
- New Kubernetes menu item allowing to switch Kubernetes context & connect to clusters other than the local one. - New Kubernetes menu item allowing to switch Kubernetes context & connect to clusters other than the local one.
* Bug fixes and minor changes * Bug fixes and minor changes
- AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset disk image (in Settings > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [backup volumes](../../storage/volumes.md#backup-restore-or-migrate-data-volumes) - AUFS storage driver is deprecated in Docker Desktop and AUFS support will be removed in the next major release. You can continue with AUFS in Docker Desktop 18.06.x, but you will need to reset disk image (in Settings > Reset menu) before updating to the next major update. You can check documentation to [save images](/engine/reference/commandline/save/#examples) and [back up volumes](../../storage/volumes.md#back-up-restore-or-migrate-data-volumes)
- Fix startup issue with AUFS - Fix startup issue with AUFS
- Fix status bug which could prevent the kubernetes cluster from starting. - Fix status bug which could prevent the kubernetes cluster from starting.
- Fix bug which would cause VM logs to be written to RAM rather than disk in some cases, and the VM to hang. - Fix bug which would cause VM logs to be written to RAM rather than disk in some cases, and the VM to hang.

View File

@ -146,7 +146,7 @@ $ docker volume rm my-vol
## Start a container with a volume ## Start a container with a volume
If you start a container with a volume that does not yet exist, Docker creates If you start a container with a volume that doesn't yet exist, Docker creates
the volume for you. The following example mounts the volume `myvol2` into the volume for you. The following example mounts the volume `myvol2` into
`/app/` in the container. `/app/` in the container.
@ -213,12 +213,11 @@ $ docker container rm devtest
$ docker volume rm myvol2 $ docker volume rm myvol2
``` ```
## Use a volume with docker-compose ## Use a volume with Docker Compose
A single docker compose service with a volume looks like this: Here's an example of a single Docker Compose service with a volume:
```yaml ```yaml
version: "{{ site.compose_file_v3 }}"
services: services:
frontend: frontend:
image: node:lts image: node:lts
@ -228,14 +227,12 @@ volumes:
myapp: myapp:
``` ```
On the first invocation of `docker-compose up` the volume will be created. The same Running `docker compose up` for the first time creates a volume. The same volume is reused when you subsequently run the command.
volume will be reused on following invocations.
A volume may be created directly outside of compose with `docker volume create` and You can create a volume directly outside of Compose using `docker volume create` and
then referenced inside `docker-compose.yml` as follows: then reference it inside `docker-compose.yml` as follows:
```yaml ```yaml
version: "{{ site.compose_file_v3 }}"
services: services:
frontend: frontend:
image: node:lts image: node:lts
@ -246,17 +243,15 @@ volumes:
external: true external: true
``` ```
For more information about using volumes with compose see For more information about using volumes with Compose, refer to the [Volumes](../compose/compose-file/index.md#volumes) section in the Compose specification.
[the compose reference](../compose/compose-file/compose-file-v3.md#volume-configuration-reference).
### Start a service with volumes ### Start a service with volumes
When you start a service and define a volume, each service container uses its own When you start a service and define a volume, each service container uses its own
local volume. None of the containers can share this data if you use the `local` local volume. None of the containers can share this data if you use the `local`
volume driver, but some volume drivers do support shared storage. Docker for AWS and volume driver. However, some volume drivers do support shared storage.
Docker for Azure both support persistent storage using the Cloudstor plugin.
The following example starts a `nginx` service with four replicas, each of which The following example starts an `nginx` service with four replicas, each of which
uses a local volume called `myvol2`. uses a local volume called `myvol2`.
```console ```console
@ -276,32 +271,32 @@ ID NAME IMAGE NODE
4d7oz1j85wwn devtest-service.1 nginx:latest moby Running Running 14 seconds ago 4d7oz1j85wwn devtest-service.1 nginx:latest moby Running Running 14 seconds ago
``` ```
Remove the service, which stops all its tasks: You can remove the service to stop the running tasks:
```console ```console
$ docker service rm devtest-service $ docker service rm devtest-service
``` ```
Removing the service does not remove any volumes created by the service. Removing the service doesn't remove any volumes created by the service.
Volume removal is a separate step. Volume removal is a separate step.
#### Syntax differences for services #### Syntax differences for services
The `docker service create` command does not support the `-v` or `--volume` flag. The `docker service create` command doesn't support the `-v` or `--volume` flag.
When mounting a volume into a service's containers, you must use the `--mount` When mounting a volume into a service's containers, you must use the `--mount`
flag. flag.
### Populate a volume using a container ### Populate a volume using a container
If you start a container which creates a new volume, as above, and the container If you start a container which creates a new volume, and the container
has files or directories in the directory to be mounted (such as `/app/` above), has files or directories in the directory to be mounted such as `/app/`,
the directory's contents are copied into the volume. The container then the directory's contents are copied into the volume. The container then
mounts and uses the volume, and other containers which use the volume also mounts and uses the volume, and other containers which use the volume also
have access to the pre-populated content. have access to the pre-populated content.
To illustrate this, this example starts an `nginx` container and populates the To illustrate this, the following example starts an `nginx` container and
new volume `nginx-vol` with the contents of the container's populates the new volume `nginx-vol` with the contents of the container's
`/usr/share/nginx/html` directory, which is where Nginx stores its default HTML `/usr/share/nginx/html` directory. This is where Nginx stores its default HTML
content. content.
The `--mount` and `-v` examples have the same end result. The `--mount` and `-v` examples have the same end result.
@ -349,14 +344,14 @@ $ docker volume rm nginx-vol
For some development applications, the container needs to write into the bind For some development applications, the container needs to write into the bind
mount so that changes are propagated back to the Docker host. At other times, mount so that changes are propagated back to the Docker host. At other times,
the container only needs read access to the data. Remember that multiple the container only needs read access to the data. Multiple
containers can mount the same volume, and it can be mounted read-write for some containers can mount the same volume. You can simultaneously mount a
of them and read-only for others, at the same time. single volume as `read-write` for some containers and as `read-only` for others.
This example modifies the one above but mounts the directory as a read-only The following example modifies the one above but mounts the directory as a read-only
volume, by adding `ro` to the (empty by default) list of options, after the volume, by adding `ro` to the (empty by default) list of options, after the
mount point within the container. Where multiple options are present, separate mount point within the container. Where multiple options are present, you can separate
them by commas. them using commas.
The `--mount` and `-v` examples have the same result. The `--mount` and `-v` examples have the same result.
@ -387,7 +382,7 @@ $ docker run -d \
</div><!--volume--> </div><!--volume-->
</div><!--tab-content--> </div><!--tab-content-->
Use `docker inspect nginxtest` to verify that the readonly mount was created Use `docker inspect nginxtest` to verify that the read-only mount was created
correctly. Look for the `Mounts` section: correctly. Look for the `Mounts` section:
```json ```json
@ -416,9 +411,9 @@ $ docker container rm nginxtest
$ docker volume rm nginx-vol $ docker volume rm nginx-vol
``` ```
## Share data among machines ## Share data between machines
When building fault-tolerant applications, you might need to configure multiple When building fault-tolerant applications, you may need to configure multiple
replicas of the same service to have access to the same files. replicas of the same service to have access to the same files.
![shared storage](images/volumes-shared-storage.svg) ![shared storage](images/volumes-shared-storage.svg)
@ -441,10 +436,10 @@ The following examples use the `vieux/sshfs` volume driver, first when creating
a standalone volume, and then when starting a container which creates a new a standalone volume, and then when starting a container which creates a new
volume. volume.
### Initial set-up ### Initial setup
This example assumes that you have two nodes, the first of which is a Docker The following example assumes that you have two nodes, the first of which is a Docker
host and can connect to the second using SSH. host and can connect to the second node using SSH.
On the Docker host, install the `vieux/sshfs` plugin: On the Docker host, install the `vieux/sshfs` plugin:
@ -454,8 +449,8 @@ $ docker plugin install --grant-all-permissions vieux/sshfs
### Create a volume using a volume driver ### Create a volume using a volume driver
This example specifies a SSH password, but if the two hosts have shared keys This example specifies an SSH password, but if the two hosts have shared keys
configured, you can omit the password. Each volume driver may have zero or more configured, you can exclude the password. Each volume driver may have zero or more
configurable options, each of which is specified using an `-o` flag. configurable options, each of which is specified using an `-o` flag.
```console ```console
@ -467,10 +462,13 @@ $ docker volume create --driver vieux/sshfs \
### Start a container which creates a volume using a volume driver ### Start a container which creates a volume using a volume driver
This example specifies a SSH password, but if the two hosts have shared keys The following example specifies an SSH password. However, if the two hosts have
configured, you can omit the password. Each volume driver may have zero or more shared keys configured, you can exclude the password. Each volume driver may have zero or more configurable options.
configurable options. **If the volume driver requires you to pass options, you
must use the `--mount` flag to mount the volume, rather than `-v`.** > **Note:**
>
> If the volume driver requires you to pass any options, you must use the `--mount` flag to mount the volume, and not `-v`.
```console ```console
$ docker run -d \ $ docker run -d \
@ -482,9 +480,10 @@ $ docker run -d \
### Create a service which creates an NFS volume ### Create a service which creates an NFS volume
This example shows how you can create an NFS volume when creating a service. This example uses `10.0.0.10` as the NFS server and `/var/docker-nfs` as the exported directory on the NFS server. Note that the volume driver specified is `local`. The following example shows how you can create an NFS volume when creating a service. It uses `10.0.0.10` as the NFS server and `/var/docker-nfs` as the exported directory on the NFS server. Note that the volume driver specified is `local`.
#### NFSv3 #### NFSv3
```console ```console
$ docker service create -d \ $ docker service create -d \
--name nfs-service \ --name nfs-service \
@ -493,6 +492,7 @@ $ docker service create -d \
``` ```
#### NFSv4 #### NFSv4
```console ```console
$ docker service create -d \ $ docker service create -d \
--name nfs-service \ --name nfs-service \
@ -514,7 +514,7 @@ $ docker volume create \
Notice the `addr` option is required if using a hostname instead of an IP so docker can perform the hostname lookup. Notice the `addr` option is required if using a hostname instead of an IP so docker can perform the hostname lookup.
## Backup, restore, or migrate data volumes ## Back up, restore, or migrate data volumes
Volumes are useful for backups, restores, and migrations. Use the Volumes are useful for backups, restores, and migrations. Use the
`--volumes-from` flag to create a new container that mounts that volume. `--volumes-from` flag to create a new container that mounts that volume.
@ -527,7 +527,7 @@ For example, create a new container named `dbstore`:
$ docker run -v /dbdata --name dbstore ubuntu /bin/bash $ docker run -v /dbdata --name dbstore ubuntu /bin/bash
``` ```
Then in the next command, we: In the next command:
- Launch a new container and mount the volume from the `dbstore` container - Launch a new container and mount the volume from the `dbstore` container
- Mount a local host directory as `/backup` - Mount a local host directory as `/backup`
@ -537,13 +537,13 @@ Then in the next command, we:
$ docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata $ docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata
``` ```
When the command completes and the container stops, we are left with a backup of When the command completes and the container stops, it creates a backup of
our `dbdata` volume. the `dbdata` volume.
### Restore volume from backup ### Restore volume from a backup
With the backup just created, you can restore it to the same container, or With the backup just created, you can restore it to the same container, or to
another that you made elsewhere. another container that you created elsewhere.
For example, create a new container named `dbstore2`: For example, create a new container named `dbstore2`:
@ -551,27 +551,27 @@ For example, create a new container named `dbstore2`:
$ docker run -v /dbdata --name dbstore2 ubuntu /bin/bash $ docker run -v /dbdata --name dbstore2 ubuntu /bin/bash
``` ```
Then un-tar the backup file in the new containers data volume: Then, un-tar the backup file in the new containers data volume:
```console ```console
$ docker run --rm --volumes-from dbstore2 -v $(pwd):/backup ubuntu bash -c "cd /dbdata && tar xvf /backup/backup.tar --strip 1" $ docker run --rm --volumes-from dbstore2 -v $(pwd):/backup ubuntu bash -c "cd /dbdata && tar xvf /backup/backup.tar --strip 1"
``` ```
You can use the techniques above to automate backup, migration and restore You can use the techniques above to automate backup, migration, and restore
testing using your preferred tools. testing using your preferred tools.
## Remove volumes ## Remove volumes
A Docker data volume persists after a container is deleted. There are two types A Docker data volume persists after you delete a container. There are two types
of volumes to consider: of volumes to consider:
- **Named volumes** have a specific source from outside the container, for example `awesome:/bar`. - Named volumes have a specific source from outside the container, for example, `awesome:/bar`.
- **Anonymous volumes** have no specific source so when the container is deleted, instruct the Docker Engine daemon to remove them. - Anonymous volumes have no specific source, therefore, when the container is deleted, you can instruct the Docker Engine daemon to remove them.
### Remove anonymous volumes ### Remove anonymous volumes
To automatically remove anonymous volumes, use the `--rm` option. For example, To automatically remove anonymous volumes, use the `--rm` option. For example,
this command creates an anonymous `/foo` volume. When the container is removed, this command creates an anonymous `/foo` volume. When you remove the container,
the Docker Engine removes the `/foo` volume but not the `awesome` volume. the Docker Engine removes the `/foo` volume but not the `awesome` volume.
```console ```console
@ -592,22 +592,6 @@ To remove all unused volumes and free up space:
$ docker volume prune $ docker volume prune
``` ```
## Next steps ## Next steps
- Learn about [bind mounts](bind-mounts.md). - Learn about [bind mounts](bind-mounts.md).