mirror of https://github.com/docker/cli.git
docs: improve introduction to docker run
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
parent
4dd5c23d6e
commit
2f48f41fcb
|
@ -1,54 +1,44 @@
|
||||||
---
|
---
|
||||||
description: "Configure containers at runtime"
|
description: "Running and configuring containers with the Docker CLI"
|
||||||
keywords: "docker, run, configure, runtime"
|
keywords: "docker, run, cli"
|
||||||
aliases:
|
aliases:
|
||||||
- /reference/run/
|
- /reference/run/
|
||||||
|
title: Running containers
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- This file is maintained within the docker/cli GitHub
|
|
||||||
repository at https://github.com/docker/cli/. Make all
|
|
||||||
pull requests against that repo. If you see this file in
|
|
||||||
another repository, consider it read-only there, as it will
|
|
||||||
periodically be overwritten by the definitive file. Pull
|
|
||||||
requests which include edits to this file in other repositories
|
|
||||||
will be rejected.
|
|
||||||
-->
|
|
||||||
|
|
||||||
# Docker run reference
|
|
||||||
|
|
||||||
Docker runs processes in isolated containers. A container is a process
|
Docker runs processes in isolated containers. A container is a process
|
||||||
which runs on a host. The host may be local or remote. When an operator
|
which runs on a host. The host may be local or remote. When an you
|
||||||
executes `docker run`, the container process that runs is isolated in
|
execute `docker run`, the container process that runs is isolated in
|
||||||
that it has its own file system, its own networking, and its own
|
that it has its own file system, its own networking, and its own
|
||||||
isolated process tree separate from the host.
|
isolated process tree separate from the host.
|
||||||
|
|
||||||
This page details how to use the `docker run` command to define the
|
This page details how to use the `docker run` command to run containers.
|
||||||
container's resources at runtime.
|
|
||||||
|
|
||||||
## General form
|
## General form
|
||||||
|
|
||||||
The basic `docker run` command takes this form:
|
A `docker run` command takes the following form:
|
||||||
|
|
||||||
$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
|
```console
|
||||||
|
$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
|
||||||
|
```
|
||||||
|
|
||||||
The `docker run` command must specify an [*IMAGE*](https://docs.docker.com/glossary/#image)
|
The `docker run` command must specify an [image](https://docs.docker.com/glossary/#image)
|
||||||
to derive the container from. An image developer can define image
|
to create the container from.
|
||||||
defaults related to:
|
|
||||||
|
|
||||||
* detached or foreground running
|
`[OPTIONS]` let you configure options for the container. For example, you can
|
||||||
* container identification
|
give the container a name (`--name`), or run it as a background process (`-d`).
|
||||||
* network settings
|
You can also set options to control things like resource constraints and
|
||||||
* runtime constraints on CPU and memory
|
networking.
|
||||||
|
|
||||||
With the `docker run [OPTIONS]` an operator can add to or override the
|
You can use the `[COMMAND]` and `[ARG...]` positional arguments to specify
|
||||||
image defaults set by a developer. And, additionally, operators can
|
commands and arguments for the container to run when it starts up. For example,
|
||||||
override nearly all the defaults set by the Docker runtime itself. The
|
you can specify `sh` as the `[COMMAND]`, combined with the `-i` and `-t` flags,
|
||||||
operator's ability to override image and Docker runtime defaults is why
|
to start an interactive shell in the container (if the image you select has an
|
||||||
[*run*](commandline/run.md) has more options than any
|
`sh` executable on `PATH`).
|
||||||
other `docker` command.
|
|
||||||
|
|
||||||
To learn how to interpret the types of `[OPTIONS]`, see
|
```console
|
||||||
[*Option types*](commandline/cli.md#option-types).
|
$ docker run -it IMAGE sh
|
||||||
|
```
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
|
@ -59,25 +49,6 @@ To learn how to interpret the types of `[OPTIONS]`, see
|
||||||
> it. For more information about this configuration, refer to the Docker
|
> it. For more information about this configuration, refer to the Docker
|
||||||
> installation documentation for your operating system.
|
> installation documentation for your operating system.
|
||||||
|
|
||||||
|
|
||||||
## Operator exclusive options
|
|
||||||
|
|
||||||
Only the operator (the person executing `docker run`) can set the
|
|
||||||
following options.
|
|
||||||
|
|
||||||
- [Detached vs foreground](#detached-vs-foreground)
|
|
||||||
- [Detached (-d)](#detached--d)
|
|
||||||
- [Foreground](#foreground)
|
|
||||||
- [Container identification](#container-identification)
|
|
||||||
- [Name (--name)](#name---name)
|
|
||||||
- [PID equivalent](#pid-equivalent)
|
|
||||||
- [IPC settings (--ipc)](#ipc-settings---ipc)
|
|
||||||
- [Network settings](#network-settings)
|
|
||||||
- [Restart policies (--restart)](#restart-policies---restart)
|
|
||||||
- [Clean up (--rm)](#clean-up---rm)
|
|
||||||
- [Runtime constraints on resources](#runtime-constraints-on-resources)
|
|
||||||
- [Runtime privilege and Linux capabilities](#runtime-privilege-and-linux-capabilities)
|
|
||||||
|
|
||||||
## Detached vs foreground
|
## Detached vs foreground
|
||||||
|
|
||||||
When starting a Docker container, you must first decide if you want to
|
When starting a Docker container, you must first decide if you want to
|
||||||
|
|
Loading…
Reference in New Issue