summaryrefslogtreecommitdiff
path: root/docs/reference/commandline/create.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/reference/commandline/create.md')
-rw-r--r--docs/reference/commandline/create.md71
1 files changed, 47 insertions, 24 deletions
diff --git a/docs/reference/commandline/create.md b/docs/reference/commandline/create.md
index e6582e4a38..00de1dc32b 100644
--- a/docs/reference/commandline/create.md
+++ b/docs/reference/commandline/create.md
@@ -132,6 +132,7 @@ Options:
--volumes-from value Mount volumes from the specified container(s) (default [])
-w, --workdir string Working directory inside the container
```
+## Description
The `docker create` command creates a writeable container layer over the
specified image and prepares it for running the specified command. The
@@ -147,42 +148,64 @@ Please see the [run command](run.md) section and the [Docker run reference](../r
## Examples
- $ docker create -t -i fedora bash
- 6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
- $ docker start -a -i 6d8af538ec5
- bash-4.2#
+### Create and start a container
+
+```bash
+$ docker create -t -i fedora bash
+
+6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
+
+$ docker start -a -i 6d8af538ec5
+
+bash-4.2#
+```
+
+### Initialize volumes
As of v1.4.0 container volumes are initialized during the `docker create` phase
(i.e., `docker run` too). For example, this allows you to `create` the `data`
volume container, and then use it from another container:
- $ docker create -v /data --name data ubuntu
- 240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
- $ docker run --rm --volumes-from data ubuntu ls -la /data
- total 8
- drwxr-xr-x 2 root root 4096 Dec 5 04:10 .
- drwxr-xr-x 48 root root 4096 Dec 5 04:11 ..
+```bash
+$ docker create -v /data --name data ubuntu
+
+240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
+
+$ docker run --rm --volumes-from data ubuntu ls -la /data
+
+total 8
+drwxr-xr-x 2 root root 4096 Dec 5 04:10 .
+drwxr-xr-x 48 root root 4096 Dec 5 04:11 ..
+```
Similarly, `create` a host directory bind mounted volume container, which can
then be used from the subsequent container:
- $ docker create -v /home/docker:/docker --name docker ubuntu
- 9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
- $ docker run --rm --volumes-from docker ubuntu ls -la /docker
- total 20
- drwxr-sr-x 5 1000 staff 180 Dec 5 04:00 .
- drwxr-xr-x 48 root root 4096 Dec 5 04:13 ..
- -rw-rw-r-- 1 1000 staff 3833 Dec 5 04:01 .ash_history
- -rw-r--r-- 1 1000 staff 446 Nov 28 11:51 .ashrc
- -rw-r--r-- 1 1000 staff 25 Dec 5 04:00 .gitconfig
- drwxr-sr-x 3 1000 staff 60 Dec 1 03:28 .local
- -rw-r--r-- 1 1000 staff 920 Nov 28 11:51 .profile
- drwx--S--- 2 1000 staff 460 Dec 5 00:51 .ssh
- drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker
+```bash
+$ docker create -v /home/docker:/docker --name docker ubuntu
+
+9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
+
+$ docker run --rm --volumes-from docker ubuntu ls -la /docker
+
+total 20
+drwxr-sr-x 5 1000 staff 180 Dec 5 04:00 .
+drwxr-xr-x 48 root root 4096 Dec 5 04:13 ..
+-rw-rw-r-- 1 1000 staff 3833 Dec 5 04:01 .ash_history
+-rw-r--r-- 1 1000 staff 446 Nov 28 11:51 .ashrc
+-rw-r--r-- 1 1000 staff 25 Dec 5 04:00 .gitconfig
+drwxr-sr-x 3 1000 staff 60 Dec 1 03:28 .local
+-rw-r--r-- 1 1000 staff 920 Nov 28 11:51 .profile
+drwx--S--- 2 1000 staff 460 Dec 5 00:51 .ssh
+drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker
+```
+
Set storage driver options per container.
- $ docker create -it --storage-opt size=120G fedora /bin/bash
+```bash
+$ docker create -it --storage-opt size=120G fedora /bin/bash
+```
This (size) will allow to set the container rootfs size to 120G at creation time.
This option is only available for the `devicemapper`, `btrfs`, `overlay2`,