Support mount opts for `local` volume driver

Allows users to submit options similar to the `mount` command when
creating a volume with the `local` volume driver.

For example:

```go
$ docker volume create -d local --opt type=nfs --opt device=myNfsServer:/data --opt o=noatime,nosuid
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2016-02-11 21:48:16 -05:00 committed by Tibor Vass
parent 09f4e2e654
commit b1bac487a6
2 changed files with 39 additions and 15 deletions

View File

@ -21,10 +21,12 @@ parent = "smn_cli"
Creates a new volume that containers can consume and store data in. If a name is not specified, Docker generates a random name. You create a volume and then configure the container to use it, for example: Creates a new volume that containers can consume and store data in. If a name is not specified, Docker generates a random name. You create a volume and then configure the container to use it, for example:
$ docker volume create --name hello ```bash
hello $ docker volume create --name hello
hello
$ docker run -d -v hello:/world busybox ls /world $ docker run -d -v hello:/world busybox ls /world
```
The mount is created inside the container's `/world` directory. Docker does not support relative paths for mount points inside the container. The mount is created inside the container's `/world` directory. Docker does not support relative paths for mount points inside the container.
@ -42,16 +44,32 @@ If you specify a volume name already in use on the current driver, Docker assume
Some volume drivers may take options to customize the volume creation. Use the `-o` or `--opt` flags to pass driver options: Some volume drivers may take options to customize the volume creation. Use the `-o` or `--opt` flags to pass driver options:
$ docker volume create --driver fake --opt tardis=blue --opt timey=wimey ```bash
$ docker volume create --driver fake --opt tardis=blue --opt timey=wimey
```
These options are passed directly to the volume driver. Options for These options are passed directly to the volume driver. Options for
different volume drivers may do different things (or nothing at all). different volume drivers may do different things (or nothing at all).
*Note*: The built-in `local` volume driver does not currently accept any options. The built-in `local` driver on Windows does not support any options.
The built-in `local` driver on Linux accepts options similar to the linux `mount`
command:
```bash
$ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000
```
Another example:
```bash
$ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2
```
## Related information ## Related information
* [volume inspect](volume_inspect.md) * [volume inspect](volume_inspect.md)
* [volume ls](volume_ls.md) * [volume ls](volume_ls.md)
* [volume rm](volume_rm.md) * [volume rm](volume_rm.md)
* [Understand Data Volumes](../../userguide/containers/dockervolumes.md) * [Understand Data Volumes](../../userguide/containers/dockervolumes.md)

View File

@ -15,11 +15,9 @@ docker-volume-create - Create a new volume
Creates a new volume that containers can consume and store data in. If a name is not specified, Docker generates a random name. You create a volume and then configure the container to use it, for example: Creates a new volume that containers can consume and store data in. If a name is not specified, Docker generates a random name. You create a volume and then configure the container to use it, for example:
``` $ docker volume create --name hello
$ docker volume create --name hello hello
hello $ docker run -d -v hello:/world busybox ls /world
$ docker run -d -v hello:/world busybox ls /world
```
The mount is created inside the container's `/src` directory. Docker doesn't not support relative paths for mount points inside the container. The mount is created inside the container's `/src` directory. Docker doesn't not support relative paths for mount points inside the container.
@ -29,14 +27,22 @@ Multiple containers can use the same volume in the same time period. This is use
Some volume drivers may take options to customize the volume creation. Use the `-o` or `--opt` flags to pass driver options: Some volume drivers may take options to customize the volume creation. Use the `-o` or `--opt` flags to pass driver options:
``` $ docker volume create --driver fake --opt tardis=blue --opt timey=wimey
$ docker volume create --driver fake --opt tardis=blue --opt timey=wimey
```
These options are passed directly to the volume driver. Options for These options are passed directly to the volume driver. Options for
different volume drivers may do different things (or nothing at all). different volume drivers may do different things (or nothing at all).
*Note*: The built-in `local` volume driver does not currently accept any options. The built-in `local` driver on Windows does not support any options.
The built-in `local` driver on Linux accepts options similar to the linux `mount`
command:
$ docker volume create --driver local --opt type=tmpfs --opt device=tmpfs --opt o=size=100m,uid=1000
Another example:
$ docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2
# OPTIONS # OPTIONS
**-d**, **--driver**="*local*" **-d**, **--driver**="*local*"