github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/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 doesn't
    45  support relative paths for mount points inside the container.
    46  
    47  Multiple containers can use the same volume. This is useful if two containers
    48  need access to shared data. For example, if one container writes and the other
    49  reads the data.
    50  
    51  Volume names must be unique among drivers. This means you can't use the same
    52  volume name with two different drivers. Attempting to create two volumes with
    53  the same name results in an 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 doesn't 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 accepts no options on Windows. On Linux and with
    78  Docker Desktop, the `local` driver accepts options similar to the Linux `mount`
    79  command. You can provide multiple options by passing the `--opt` flag multiple
    80  times. Some `mount` options (such as the `o` option) can take a comma-separated
    81  list of options. Complete list of available mount options can be found
    82  [here](https://man7.org/linux/man-pages/man8/mount.8.html).
    83  
    84  For example, the following creates a `tmpfs` volume called `foo` with a size of
    85  100 megabyte and `uid` of 1000.
    86  
    87  ```console
    88  $ docker volume create --driver local \
    89      --opt type=tmpfs \
    90      --opt device=tmpfs \
    91      --opt o=size=100m,uid=1000 \
    92      foo
    93  ```
    94  
    95  Another example that uses `btrfs`:
    96  
    97  ```console
    98  $ docker volume create --driver local \
    99      --opt type=btrfs \
   100      --opt device=/dev/sda2 \
   101      foo
   102  ```
   103  
   104  Another example that uses `nfs` to mount the `/path/to/dir` in `rw` mode from
   105  `192.168.1.1`:
   106  
   107  ```console
   108  $ docker volume create --driver local \
   109      --opt type=nfs \
   110      --opt o=addr=192.168.1.1,rw \
   111      --opt device=:/path/to/dir \
   112      foo
   113  ```
   114  
   115  ## Related commands
   116  
   117  * [volume inspect](volume_inspect.md)
   118  * [volume ls](volume_ls.md)
   119  * [volume rm](volume_rm.md)
   120  * [volume prune](volume_prune.md)
   121  * [Understand Data Volumes](https://docs.docker.com/storage/volumes/)