1
0
mirror of https://github.com/docker/cli.git synced 2026-01-16 20:22:36 +03:00
Files
cli/components/engine/docs/sources/commandline/command/run.rst
Thatcher Peskens 7e99f4ac78 Updated the description of run -d
The goal is to make it more clear this will give you the container id after run completes.

Since stdout is now standard on run, "docker run -d" is the best (or only) way to get the container ID returned from docker after a plain run, but the description (help) does not hint any such thing.
Upstream-commit: 5dc86d7bca17c2996264a18cc26f06d30e532588
Component: engine
2013-07-29 14:17:15 -07:00

1.6 KiB

title
Run Command
description
Run a command in a new container
keywords
run, container, docker, documentation

run -- Run a command in a new container

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

  -a=map[]: Attach to stdin, stdout or stderr.
  -c=0: CPU shares (relative weight)
  -cidfile="": Write the container ID to the file
  -d=false: Detached mode: Run container in the background, print new container id
  -e=[]: Set environment variables
  -h="": Container host name
  -i=false: Keep stdin open even if not attached
  -m=0: Memory limit (in bytes)
  -n=true: Enable networking for this container
  -p=[]: Map a network port to the container
  -t=false: Allocate a pseudo-tty
  -u="": Username or UID
  -d=[]: Set custom dns servers for the container
  -v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "host-dir" is missing, then docker creates a new volume.
  -volumes-from="": Mount all volumes from the given container.
  -entrypoint="": Overwrite the default entrypoint set by the image.

Examples

docker run -cidfile /tmp/docker_test.cid ubuntu echo "test"
This will create a container and print "test" to the console. The cidfile flag makes docker attempt to create a new file and write the container ID to it. If the file exists already, docker will return an error. Docker will close this file when docker run exits.