You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Mounts` allows users to specify in a much safer way the volumes they
want to use in the container.
This replaces `Binds` and `Volumes`, which both still exist, but
`Mounts` and `Binds`/`Volumes` are exclussive.
The CLI will continue to use `Binds` and `Volumes` due to concerns with
parsing the volume specs on the client side and cross-platform support
(for now).
The new API follows exactly the services mount API.
Example usage of `Mounts`:
```
$ curl -XPOST localhost:2375/containers/create -d '{
"Image": "alpine:latest",
"HostConfig": {
"Mounts": [{
"Type": "Volume",
"Target": "/foo"
},{
"Type": "bind",
"Source": "/var/run/docker.sock",
"Target": "/var/run/docker.sock",
},{
"Type": "volume",
"Name": "important_data",
"Target": "/var/data",
"ReadOnly": true,
"VolumeOptions": {
"DriverConfig": {
Name: "awesomeStorage",
Options: {"size": "10m"},
Labels: {"some":"label"}
}
}]
}
}'
```
There are currently 2 types of mounts:
- **bind**: Paths on the host that get mounted into the
container. Paths must exist prior to creating the container.
- **volume**: Volumes that persist after the
container is removed.
Not all fields are available in each type, and validation is done to
ensure these fields aren't mixed up between types.
Signed-off-by: Brian Goff <[email protected]>
Copy file name to clipboardExpand all lines: docs/reference/api/docker_remote_api.md
+1
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,7 @@ This section lists each version from latest to oldest. Each listing includes a
122
122
*`DELETE /volumes/(name)` now accepts a `force` query parameter to force removal of volumes that were already removed out of band by the volume driver plugin.
123
123
*`POST /containers/create/` and `POST /containers/(name)/update` now validates restart policies.
124
124
*`POST /containers/create` now validates IPAMConfig in NetworkingConfig, and returns error for invalid IPv4 and IPv6 addresses (`--ip` and `--ip6` in `docker create/run`).
125
+
*`POST /containers/create` now takes a `Mounts` field in `HostConfig` which replaces `Binds` and `Volumes`. *note*: `Binds` and `Volumes` are still available but are exclusive with `Mounts`
Copy file name to clipboardExpand all lines: docs/reference/api/docker_remote_api_v1.25.md
+18
Original file line number
Diff line number
Diff line change
@@ -486,6 +486,24 @@ Create a container
486
486
-**CgroupParent** - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist.
487
487
-**VolumeDriver** - Driver that this container users to mount volumes.
488
488
-**ShmSize** - Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB.
489
+
-**Mounts** – Specification for mounts to be added to the container.
490
+
-**Target** – Container path.
491
+
-**Source** – Mount source (e.g. a volume name, a host path).
492
+
-**Type** – The mount type (`bind`, or `volume`).
493
+
Available types (for the `Type` field):
494
+
-**bind** - Mounts a file or directory from the host into the container. Must exist prior to creating the container.
495
+
-**volume** - Creates a volume with the given name and options (or uses a pre-existing volume with the same name and options). These are **not** removed when the container is removed.
496
+
-**ReadOnly** – A boolean indicating whether the mount should be read-only.
497
+
-**BindOptions** - Optional configuration for the `bind` type.
498
+
-**Propagation** – A propagation mode with the value `[r]private`, `[r]shared`, or `[r]slave`.
499
+
-**VolumeOptions** – Optional configuration for the `volume` type.
500
+
-**NoCopy** – A boolean indicating if volume should be
501
+
populated with the data from the target. (Default false)
502
+
-**Labels** – User-defined name and labels for the volume as key/value pairs: `{"name": "value"}`
503
+
-**DriverConfig** – Map of driver-specific options.
504
+
-**Name** - Name of the driver to use to create the volume.
505
+
-**Options** - key/value map of driver specific options.
0 commit comments