docker-latest-run (1) - Linux Manuals
docker-latest-run: Run a command in a new container
NAME
docker-run - Run a command in a new container
SYNOPSIS
docker run [-a|--attach[=[]]] [--add-host[=[]]] [--blkio-weight[=[BLKIO-WEIGHT]]] [--blkio-weight-device[=[]]] [--cpu-shares[=0]] [--cap-add[=[]]] [--cap-drop[=[]]] [--cgroup-parent[=CGROUP-PATH]] [--cidfile[=CIDFILE]] [--cpu-period[=0]] [--cpu-quota[=0]] [--cpuset-cpus[=CPUSET-CPUS]] [--cpuset-mems[=CPUSET-MEMS]] [-d|--detach] [--detach-keys[=[]]] [--device[=[]]] [--device-read-bps[=[]]] [--device-read-iops[=[]]] [--device-write-bps[=[]]] [--device-write-iops[=[]]] [--dns[=[]]] [--dns-opt[=[]]] [--dns-search[=[]]] [-e|--env[=[]]] [--entrypoint[=ENTRYPOINT]] [--env-file[=[]]] [--expose[=[]]] [--group-add[=[]]] [-h|--hostname[=HOSTNAME]] [--help] [-i|--interactive] [--ip[=IPv4-ADDRESS]] [--ip6[=IPv6-ADDRESS]] [--ipc[=IPC]] [--isolation[=default]] [--kernel-memory[=KERNEL-MEMORY]] [-l|--label[=[]]] [--label-file[=[]]] [--link[=[]]] [--link-local-ip[=[]]] [--log-driver[=[]]] [--log-opt[=[]]] [-m|--memory[=MEMORY]] [--mac-address[=MAC-ADDRESS]] [--memory-reservation[=MEMORY-RESERVATION]] [--memory-swap[=LIMIT]] [--memory-swappiness[=MEMORY-SWAPPINESS]] [--name[=NAME]] [--network-alias[=[]]] [--network[="bridge"]] [--oom-kill-disable] [--oom-score-adj[=0]] [-P|--publish-all] [-p|--publish[=[]]] [--pid[=[PID]]] [--userns[=[]]] [--pids-limit[=PIDS_LIMIT]] [--privileged] [--read-only] [--restart[=RESTART]] [--rm] [--security-opt[=[]]] [--storage-opt[=[]]] [--stop-signal[=SIGNAL]] [--shm-size[=[]]] [--sig-proxy[=true]] [--sysctl[=[]]] [-t|--tty] [--tmpfs[=[CONTAINER-DIR[:<OPTIONS>]]] [-u|--user[=USER]] [--ulimit[=[]]] [--uts[=[]]] [-v|--volume[=[[HOST-DIR:]CONTAINER-DIR[:OPTIONS]]]] [--volume-driver[=DRIVER]] [--volumes-from[=[]]] [-w|--workdir[=WORKDIR]] IMAGE [COMMAND] [ARG...]
DESCRIPTION
Run a process in a new container. docker run starts a process with its own file system, its own networking, and its own isolated process tree. The IMAGE which starts the process may define defaults related to the process that will be run in the container, the networking to expose, and more, but docker run gives final control to the operator or administrator who starts the container from the image. For that reason docker run has more options than any other Docker command.
If the IMAGE is not already loaded then docker run will pull the IMAGE, and all image dependencies, from the repository in the same way running docker pull IMAGE, before it starts the container from that image.
OPTIONS
-a, --attach=[]
Attach to STDIN, STDOUT or STDERR.
In foreground mode (the default when -d is not specified), docker run can start the process in the container and attach the console to the process's standard input, output, and standard error. It can even pretend to be a TTY (this is what most commandline executables expect) and pass along signals. The -a option can be set for each of stdin, stdout, and stderr.
--add-host=[]
Add a line to /etc/hosts. The format is hostname:ip. The --add-host
option can be set multiple times.
--blkio-weight=0
--blkio-weight-device=[]
--cpu-shares=0
By default, all containers get the same proportion of CPU cycles. This proportion
can be modified by changing the container's CPU share weighting relative
to the weighting of all other running containers.
To modify the proportion from the default of 1024, use the --cpu-shares
flag to set the weighting to 2 or higher.
The proportion will only apply when CPU-intensive processes are running.
When tasks in one container are idle, other containers can use the
left-over CPU time. The actual amount of CPU time will vary depending on
the number of containers running on the system.
For example, consider three containers, one has a cpu-share of 1024 and
two others have a cpu-share setting of 512. When processes in all three
containers attempt to use 100% of CPU, the first container would receive
50% of the total CPU time. If you add a fourth container with a cpu-share
of 1024, the first container only gets 33% of the CPU. The remaining containers
receive 16.5%, 16.5% and 33% of the CPU.
On a multi-core system, the shares of CPU time are distributed over all CPU
cores. Even if a container is limited to less than 100% of CPU time, it can
use 100% of each individual CPU core.
For example, consider a system with more than three cores. If you start one
container {C0} with -c=512 running one process, and another container
{C1} with -c=1024 running two processes, this can result in the following
division of CPU shares:
--cap-add=[]
--cap-drop=[]
--cgroup-parent=""
--cidfile=""
--cpu-period=0
Limit the container's CPU usage. This flag tell the kernel to restrict the container's CPU usage to the period you specify.
--cpuset-cpus=""
--cpuset-mems=""
If you have four memory nodes on your system (0-3), use --cpuset-mems=0,1
then processes in your Docker container will only use memory from the first
two memory nodes.
--cpu-quota=0
Limit the container's CPU usage. By default, containers run with the full
CPU resource. This flag tell the kernel to restrict the container's CPU usage
to the quota you specify.
-d, --detach=true|false
At any time you can run docker ps in
the other shell to view a list of the running containers. You can reattach to a
detached container with docker attach. If you choose to run a container in
the detached mode, then you cannot use the -rm option.
When attached in the tty mode, you can detach from the container (and leave it
running) using a configurable key sequence. The default sequence is CTRL-p CTRL-q.
You configure the key sequence using the --detach-keys option or a configuration file.
See config-json(5) for documentation on using a configuration file.
--detach-keys=""
--device=[]
--device-read-bps=[]
--device-read-iops=[]
--device-write-bps=[]
--device-write-iops=[]
--dns-search=[]
--dns-opt=[]
--dns=[]
This option can be used to override the DNS
configuration passed to the container. Typically this is necessary when the
host DNS configuration is invalid for the container (e.g., 127.0.0.1). When this
is the case the --dns flags is necessary for every run.
-e, --env=[]
This option allows you to specify arbitrary
environment variables that are available for the process that will be launched
inside of the container.
--entrypoint=""
This option allows you to overwrite the default entrypoint of the image that
is set in the Dockerfile. The ENTRYPOINT of an image is similar to a COMMAND
because it specifies what executable to run when the container starts, but it is
(purposely) more difficult to override. The ENTRYPOINT gives a container its
default nature or behavior, so that when you set an ENTRYPOINT you can run the
container as if it were that binary, complete with default options, and you can
pass in more options via the COMMAND. But, sometimes an operator may want to run
something else inside the container, so you can override the default ENTRYPOINT
at runtime by using a --entrypoint and a string to specify the new
ENTRYPOINT.
--env-file=[]
--expose=[]
--group-add=[]
-h, --hostname=""
Sets the container host name that is available inside the container.
--help
-i, --interactive=true|false
When set to true, keep stdin open even if not attached. The default is false.
--ip=""
It can only be used in conjunction with --net for user-defined networks
--ip6=""
It can only be used in conjunction with --net for user-defined networks
--ipc=""
--isolation="default"
-l, --label=[]
--kernel-memory=""
Constrains the kernel memory available to a container. If a limit of 0
is specified (not using --kernel-memory), the container's kernel memory
is not limited. If you specify a limit, it may be rounded up to a multiple
of the operating system's page size and the value can be very large,
millions of trillions.
--label-file=[]
--link=[]
If the operator
uses --link when starting the new client container, then the client
container can access the exposed port via a private networking interface. Docker
will set some environment variables in the client container to help indicate
which interface and port to use.
--link-local-ip=[]
--log-driver="json-file|syslog|journald|gelf|fluentd|awslogs|splunk|etwlogs|gcplogs|none"
--log-opt=[]
-m, --memory=""
Allows you to constrain the memory available to a container. If the host
supports swap memory, then the -m memory setting can be larger than physical
RAM. If a limit of 0 is specified (not using -m), the container's memory is
not limited. The actual limit may be rounded up to a multiple of the operating
system's page size (the value would be very large, that's millions of trillions).
--memory-reservation=""
After setting memory reservation, when the system detects memory contention
or low memory, containers are forced to restrict their consumption to their
reservation. So you should always set the value below --memory, otherwise the
hard limit will take precedence. By default, memory reservation will be the same
as memory limit.
--memory-swap="LIMIT"
The format of LIMIT is <number>[<unit>]. Unit can be b (bytes),
k (kilobytes), m (megabytes), or g (gigabytes). If you don't specify a
unit, b is used. Set LIMIT to -1 to enable unlimited swap.
--mac-address=""
Remember that the MAC address in an Ethernet network must be unique.
The IPv6 link-local address will be based on the device's MAC address
according to RFC4862.
--name=""
The operator can identify a container in three ways:
The UUID identifiers come from the Docker daemon, and if a name is not assigned
to the container with --name then the daemon will also generate a random
string name. The name is useful when defining links (see --link) (or any
other place you need to identify a container). This works for both background
and foreground Docker containers.
--net="bridge"
Add a custom host-to-IP mapping
Block IO weight
Block IO weight
CPU shares
PID container CPU CPU share
100 {C0} 0 100% of CPU0
101 {C1} 1 100% of CPU1
102 {C1} 2 100% of CPU2
Add Linux capabilities
Drop Linux capabilities
Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
Write the container ID to the file
Limit the CPU CFS
CPUs in which to allow execution
Memory nodes
Limit the CPU CFS
Detached mode: run the container in the background and print the new container ID. The default is
Override the key sequence for detaching a container. Format is a single character
Add a host device to the container
Limit read rate from a device
Limit read rate from a device
Limit write rate to a device
Limit write rate to a device
Set custom DNS search domains
Set custom DNS options
Set custom DNS servers
Set environment variables
Overwrite the default ENTRYPOINT of the image
Read in a line delimited file of environment variables
Expose a port, or a range of ports
Add additional groups to run as
Container host name
Keep STDIN open even if not attached. The default is
Sets the container's interface IPv4 address
Sets the container's interface IPv6 address
Default is to create a private IPC namespace
Isolation specifies the type of isolation technology used by containers. Note
that the default on Windows server is process, and the default on Windows client
is hyperv. Linux only supports default.
Set metadata on the container
Kernel memory limit
Read in a line delimited file of labels
Add link to another container in the form of
Add one or more link-local IPv4/IPv6 addresses to the container's interface
Memory limit
Memory soft limit
A limit value equal to memory plus swap. Must be used with the
Container MAC address
Assign a name to the container
Set the Network mode for the container