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