github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/docs/reference/commandline/volume_create.md (about)

     1  ---
     2  title: "volume create"
     3  description: "The volume create command description and usage"
     4  keywords: "volume, create"
     5  ---
     6  
     7  # volume create
     8  
     9  ```markdown
    10  Usage:  docker volume create [OPTIONS] [VOLUME]
    11  
    12  Create a volume
    13  
    14  Options:
    15    -d, --driver string   Specify volume driver name (default "local")
    16        --help            Print usage
    17        --label value     Set metadata for a volume (default [])
    18    -o, --opt value       Set driver specific options (default map[])
    19  ```
    20  
    21  ## Description
    22  
    23  Creates a new volume that containers can consume and store data in. If a name is
    24  not specified, Docker generates a random name.
    25  
    26  ## Examples
    27  
    28  Create a volume and then configure the container to use it:
    29  
    30  ```bash
    31  $ docker volume create hello
    32  
    33  hello
    34  
    35  $ docker run -d -v hello:/world busybox ls /world
    36  ```
    37  
    38  The mount is created inside the container's `/world` directory. Docker does not
    39  support relative paths for mount points inside the container.
    40  
    41  Multiple containers can use the same volume in the same time period. This is
    42  useful if two containers need access to shared data. For example, if one
    43  container writes and the other reads the data.
    44  
    45  Volume names must be unique among drivers. This means you cannot use the same
    46  volume name with two different drivers. If you attempt this `docker` returns an
    47  error:
    48  
    49  ```console
    50  A volume named  "hello"  already exists with the "some-other" driver. Choose a different volume name.
    51  ```
    52  
    53  If you specify a volume name already in use on the current driver, Docker
    54  assumes you want to re-use the existing volume and does not return an error.
    55  
    56  ### Driver-specific options
    57  
    58  Some volume drivers may take options to customize the volume creation. Use the
    59  `-o` or `--opt` flags to pass driver options:
    60  
    61  ```bash
    62  $ docker volume create --driver fake \
    63      --opt tardis=blue \
    64      --opt timey=wimey \
    65      foo
    66  ```
    67  
    68  These options are passed directly to the volume driver. Options for
    69  different volume drivers may do different things (or nothing at all).
    70  
    71  The built-in `local` driver on Windows does not support any options.
    72  
    73  The built-in `local` driver on Linux accepts options similar to the linux
    74  `mount` command. You can provide multiple options by passing the `--opt` flag
    75  multiple times. Some `mount` options (such as the `o` option) can take a
    76  comma-separated list of options. Complete list of available mount options can be
    77  found [here](http://man7.org/linux/man-pages/man8/mount.8.html).
    78  
    79  For example, the following creates a `tmpfs` volume called `foo` with a size of
    80  100 megabyte and `uid` of 1000.
    81  
    82  ```bash
    83  $ docker volume create --driver local \
    84      --opt type=tmpfs \
    85      --opt device=tmpfs \
    86      --opt o=size=100m,uid=1000 \
    87      foo
    88  ```
    89  
    90  Another example that uses `btrfs`:
    91  
    92  ```bash
    93  $ docker volume create --driver local \
    94      --opt type=btrfs \
    95      --opt device=/dev/sda2 \
    96      foo
    97  ```
    98  
    99  Another example that uses `nfs` to mount the `/path/to/dir` in `rw` mode from
   100  `192.168.1.1`:
   101  
   102  ```bash
   103  $ docker volume create --driver local \
   104      --opt type=nfs \
   105      --opt o=addr=192.168.1.1,rw \
   106      --opt device=:/path/to/dir \
   107      foo
   108  ```
   109  
   110  ## Related commands
   111  
   112  * [volume inspect](volume_inspect.md)
   113  * [volume ls](volume_ls.md)
   114  * [volume rm](volume_rm.md)
   115  * [volume prune](volume_prune.md)
   116  * [Understand Data Volumes](https://docs.docker.com/storage/volumes/)