From 5886a029807ba06430516fb6e798c11a7aea8977 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 10 Mar 2014 14:11:23 +0100 Subject: [PATCH] Add "docker create" support This exposes the already existing "create container" operation. It is very similar to "docker run -d" except it doesn't actually start the container, but just prepares it. It can then be manually started using "docker start" at any point. Docker-DCO-1.1-Signed-off-by: Alexander Larsson (github: alexlarsson) Conflicts: api/client/commands.go runconfig/parse.go server/container.go Docker-DCO-1.1-Signed-off-by: Tibor Vass (github: tiborvass) --- docs/sources/reference/commandline/cli.md | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/docs/sources/reference/commandline/cli.md b/docs/sources/reference/commandline/cli.md index 0920917f93..57c7d528b0 100644 --- a/docs/sources/reference/commandline/cli.md +++ b/docs/sources/reference/commandline/cli.md @@ -370,6 +370,63 @@ path. Paths are relative to the root of the filesystem. Copy files/folders from the PATH to the HOSTPATH + +## create + +Creates a new container. + + Usage: docker create [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] + + + -a, --attach=[] Attach to stdin, stdout or stderr. + -c, --cpu-shares=0 CPU shares (relative weight) + --cidfile="" Write the container ID to the file + --dns=[] Set custom dns servers + --dns-search=[] Set custom dns search domains + -e, --env=[] Set environment variables + --entrypoint="" Overwrite the default entrypoint of the image + --env-file=[] Read in a line delimited file of ENV variables + --expose=[] Expose a port from the container without publishing it to your host + -h, --hostname="" Container host name + -i, --interactive=false Keep stdin open even if not attached + --link=[] Add link to another container (name:alias) + --lxc-conf=[] (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1" + -m, --memory="" Memory limit (format: , where unit = b, k, m or g) + --name="" Assign a name to the container + --net="bridge" Set the Network mode for the container + 'bridge': creates a new network stack for the container on the docker bridge + 'none': no networking for this container + 'container:': reuses another container network stack + 'host': use the host network stack inside the contaner + -p, --publish=[] Publish a container's port to the host + format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort + (use 'docker port' to see the actual mapping) + -P, --publish-all=false Publish all exposed ports to the host interfaces + --privileged=false Give extended privileges to this container + -t, --tty=false Allocate a pseudo-tty + -u, --user="" Username or UID + -v, --volume=[] Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container) + --volumes-from=[] Mount volumes from the specified container(s) + -w, --workdir="" Working directory inside the container + + +The `docker create` command `creates` a writeable container layer over +the specified image, and prepares it for running the specified +command. The container id is then printed to stdout. This is similar +to what `docker run -d `, does except the container is never +started. You can then use the `docker start ` command to +start the container at any point. + +This is useful when you want to set up a container configuration ahead +of time, so that it is ready to start when you need it. + +### Example: + + $ sudo docker create -t -i fedora bash + 6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752 + $ sudo docker start -a -i 6d8af538ec5 + bash-4.2# + ## diff List the changed files and directories in a container᾿s filesystem