github.com/panekj/cli@v0.0.0-20230304125325-467dd2f3797e/docs/reference/commandline/volume_create.md (about)

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