summaryrefslogtreecommitdiff
path: root/devdocs/docker/engine%2Freference%2Fcommandline%2Fcontainer_create%2Findex.html
blob: 6bdf9147c3ea989159403e6ea555ce989656dffa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<h1>docker container create</h1>  <p><br></p> <p>Create a new container</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker container create [OPTIONS] IMAGE [COMMAND] [ARG...]
</pre></div> <h2 id="options">Options</h2> <table> <thead> <tr> <td>Name, shorthand</td> <td>Default</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td><code class="language-plaintext highlighter-rouge">--add-host</code></td> <td></td> <td>Add a custom host-to-IP mapping (host:ip)</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--attach</code> , <code class="language-plaintext highlighter-rouge">-a</code>
</td> <td></td> <td>Attach to STDIN, STDOUT or STDERR</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--blkio-weight</code></td> <td></td> <td>Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--blkio-weight-device</code></td> <td></td> <td>Block IO weight (relative device weight)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cap-add</code></td> <td></td> <td>Add Linux capabilities</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cap-drop</code></td> <td></td> <td>Drop Linux capabilities</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cgroup-parent</code></td> <td></td> <td>Optional parent cgroup for the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cgroupns</code></td> <td></td> <td>
<a href="https://docs.docker.com/engine/api/v1.41/" target="_blank" rel="noopener" class="_"><span class="badge badge-info" data-toggle="tooltip" title="Open the  API reference (in a new window)">API 1.41+</span></a><br>Cgroup namespace to use (host|private) 'host': Run the container in the Docker host's cgroup namespace 'private': Run the container in its own private cgroup namespace '': Use the cgroup namespace as configured by the default-cgroupns-mode option on the daemon (default)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cidfile</code></td> <td></td> <td>Write the container ID to the file</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpu-count</code></td> <td></td> <td>CPU count (Windows only)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpu-percent</code></td> <td></td> <td>CPU percent (Windows only)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpu-period</code></td> <td></td> <td>Limit CPU CFS (Completely Fair Scheduler) period</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpu-quota</code></td> <td></td> <td>Limit CPU CFS (Completely Fair Scheduler) quota</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpu-rt-period</code></td> <td></td> <td>Limit CPU real-time period in microseconds</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpu-rt-runtime</code></td> <td></td> <td>Limit CPU real-time runtime in microseconds</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--cpu-shares</code> , <code class="language-plaintext highlighter-rouge">-c</code>
</td> <td></td> <td>CPU shares (relative weight)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpus</code></td> <td></td> <td>Number of CPUs</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpuset-cpus</code></td> <td></td> <td>CPUs in which to allow execution (0-3, 0,1)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--cpuset-mems</code></td> <td></td> <td>MEMs in which to allow execution (0-3, 0,1)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--device</code></td> <td></td> <td>Add a host device to the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--device-cgroup-rule</code></td> <td></td> <td>Add a rule to the cgroup allowed devices list</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--device-read-bps</code></td> <td></td> <td>Limit read rate (bytes per second) from a device</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--device-read-iops</code></td> <td></td> <td>Limit read rate (IO per second) from a device</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--device-write-bps</code></td> <td></td> <td>Limit write rate (bytes per second) to a device</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--device-write-iops</code></td> <td></td> <td>Limit write rate (IO per second) to a device</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--disable-content-trust</code></td> <td><code class="language-plaintext highlighter-rouge">true</code></td> <td>Skip image verification</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--dns</code></td> <td></td> <td>Set custom DNS servers</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--dns-opt</code></td> <td></td> <td>Set DNS options</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--dns-option</code></td> <td></td> <td>Set DNS options</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--dns-search</code></td> <td></td> <td>Set custom DNS search domains</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--domainname</code></td> <td></td> <td>Container NIS domain name</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--entrypoint</code></td> <td></td> <td>Overwrite the default ENTRYPOINT of the image</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--env</code> , <code class="language-plaintext highlighter-rouge">-e</code>
</td> <td></td> <td>Set environment variables</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--env-file</code></td> <td></td> <td>Read in a file of environment variables</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--expose</code></td> <td></td> <td>Expose a port or a range of ports</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--gpus</code></td> <td></td> <td>
<a href="https://docs.docker.com/engine/api/v1.40/" target="_blank" rel="noopener" class="_"><span class="badge badge-info" data-toggle="tooltip" title="Open the  API reference (in a new window)">API 1.40+</span></a><br>GPU devices to add to the container ('all' to pass all GPUs)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--group-add</code></td> <td></td> <td>Add additional groups to join</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--health-cmd</code></td> <td></td> <td>Command to run to check health</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--health-interval</code></td> <td></td> <td>Time between running the check (ms|s|m|h) (default 0s)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--health-retries</code></td> <td></td> <td>Consecutive failures needed to report unhealthy</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--health-start-period</code></td> <td></td> <td>Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--health-timeout</code></td> <td></td> <td>Maximum time to allow one check to run (ms|s|m|h) (default 0s)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--help</code></td> <td></td> <td>Print usage</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--hostname</code> , <code class="language-plaintext highlighter-rouge">-h</code>
</td> <td></td> <td>Container host name</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--init</code></td> <td></td> <td>Run an init inside the container that forwards signals and reaps processes</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--interactive</code> , <code class="language-plaintext highlighter-rouge">-i</code>
</td> <td></td> <td>Keep STDIN open even if not attached</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--io-maxbandwidth</code></td> <td></td> <td>Maximum IO bandwidth limit for the system drive (Windows only)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--io-maxiops</code></td> <td></td> <td>Maximum IOps limit for the system drive (Windows only)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--ip</code></td> <td></td> <td>IPv4 address (e.g., 172.30.100.104)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--ip6</code></td> <td></td> <td>IPv6 address (e.g., 2001:db8::33)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--ipc</code></td> <td></td> <td>IPC mode to use</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--isolation</code></td> <td></td> <td>Container isolation technology</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--kernel-memory</code></td> <td></td> <td>Kernel memory limit</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--label</code> , <code class="language-plaintext highlighter-rouge">-l</code>
</td> <td></td> <td>Set meta data on a container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--label-file</code></td> <td></td> <td>Read in a line delimited file of labels</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--link</code></td> <td></td> <td>Add link to another container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--link-local-ip</code></td> <td></td> <td>Container IPv4/IPv6 link-local addresses</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--log-driver</code></td> <td></td> <td>Logging driver for the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--log-opt</code></td> <td></td> <td>Log driver options</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--mac-address</code></td> <td></td> <td>Container MAC address (e.g., 92:d0:c6:0a:29:33)</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--memory</code> , <code class="language-plaintext highlighter-rouge">-m</code>
</td> <td></td> <td>Memory limit</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--memory-reservation</code></td> <td></td> <td>Memory soft limit</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--memory-swap</code></td> <td></td> <td>Swap limit equal to memory plus swap: '-1' to enable unlimited swap</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--memory-swappiness</code></td> <td><code class="language-plaintext highlighter-rouge">-1</code></td> <td>Tune container memory swappiness (0 to 100)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--mount</code></td> <td></td> <td>Attach a filesystem mount to the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--name</code></td> <td></td> <td>Assign a name to the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--net</code></td> <td></td> <td>Connect a container to a network</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--net-alias</code></td> <td></td> <td>Add network-scoped alias for the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--network</code></td> <td></td> <td>Connect a container to a network</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--network-alias</code></td> <td></td> <td>Add network-scoped alias for the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--no-healthcheck</code></td> <td></td> <td>Disable any container-specified HEALTHCHECK</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--oom-kill-disable</code></td> <td></td> <td>Disable OOM Killer</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--oom-score-adj</code></td> <td></td> <td>Tune host's OOM preferences (-1000 to 1000)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--pid</code></td> <td></td> <td>PID namespace to use</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--pids-limit</code></td> <td></td> <td>Tune container pids limit (set -1 for unlimited)</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--platform</code></td> <td></td> <td>Set platform if server is multi-platform capable</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--privileged</code></td> <td></td> <td>Give extended privileges to this container</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--publish</code> , <code class="language-plaintext highlighter-rouge">-p</code>
</td> <td></td> <td>Publish a container's port(s) to the host</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--publish-all</code> , <code class="language-plaintext highlighter-rouge">-P</code>
</td> <td></td> <td>Publish all exposed ports to random ports</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--pull</code></td> <td><code class="language-plaintext highlighter-rouge">missing</code></td> <td>Pull image before creating ("always"|"missing"|"never")</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--read-only</code></td> <td></td> <td>Mount the container's root filesystem as read only</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--restart</code></td> <td><code class="language-plaintext highlighter-rouge">no</code></td> <td>Restart policy to apply when a container exits</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--rm</code></td> <td></td> <td>Automatically remove the container when it exits</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--runtime</code></td> <td></td> <td>Runtime to use for this container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--security-opt</code></td> <td></td> <td>Security Options</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--shm-size</code></td> <td></td> <td>Size of /dev/shm</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--stop-signal</code></td> <td><code class="language-plaintext highlighter-rouge">SIGTERM</code></td> <td>Signal to stop a container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--stop-timeout</code></td> <td></td> <td>Timeout (in seconds) to stop a container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--storage-opt</code></td> <td></td> <td>Storage driver options for the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--sysctl</code></td> <td></td> <td>Sysctl options</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--tmpfs</code></td> <td></td> <td>Mount a tmpfs directory</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--tty</code> , <code class="language-plaintext highlighter-rouge">-t</code>
</td> <td></td> <td>Allocate a pseudo-TTY</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--ulimit</code></td> <td></td> <td>Ulimit options</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--user</code> , <code class="language-plaintext highlighter-rouge">-u</code>
</td> <td></td> <td>Username or UID (format: &lt;name|uid&gt;[:&lt;group|gid&gt;])</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--userns</code></td> <td></td> <td>User namespace to use</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--uts</code></td> <td></td> <td>UTS namespace to use</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--volume</code> , <code class="language-plaintext highlighter-rouge">-v</code>
</td> <td></td> <td>Bind mount a volume</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--volume-driver</code></td> <td></td> <td>Optional volume driver for the container</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--volumes-from</code></td> <td></td> <td>Mount volumes from the specified container(s)</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--workdir</code> , <code class="language-plaintext highlighter-rouge">-w</code>
</td> <td></td> <td>Working directory inside the container</td> </tr>  </tbody> </table>  <h2 id="parent-command">Parent command</h2> <table> <thead> <tr> <th style="text-align: left">Command</th> <th style="text-align: left">Description</th> </tr> </thead> <tbody> <tr> <td style="text-align: left"><a href="../container/index">docker container</a></td> <td style="text-align: left">Manage containers</td> </tr> </tbody> </table> <h2 id="related-commands">Related commands</h2> <table> <thead> <tr> <td>Command</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td><a href="../container_attach/index">docker container attach</a></td> <td>Attach local standard input, output, and error streams to a running container</td> </tr> <tr> <td><a href="../container_commit/index">docker container commit</a></td> <td>Create a new image from a container’s changes</td> </tr> <tr> <td><a href="../container_cp/index">docker container cp</a></td> <td>Copy files/folders between a container and the local filesystem</td> </tr> <tr> <td><a href="index">docker container create</a></td> <td>Create a new container</td> </tr> <tr> <td><a href="../container_diff/index">docker container diff</a></td> <td>Inspect changes to files or directories on a container’s filesystem</td> </tr> <tr> <td><a href="../container_exec/index">docker container exec</a></td> <td>Run a command in a running container</td> </tr> <tr> <td><a href="../container_export/index">docker container export</a></td> <td>Export a container’s filesystem as a tar archive</td> </tr> <tr> <td><a href="../container_inspect/index">docker container inspect</a></td> <td>Display detailed information on one or more containers</td> </tr> <tr> <td><a href="../container_kill/index">docker container kill</a></td> <td>Kill one or more running containers</td> </tr> <tr> <td><a href="../container_logs/index">docker container logs</a></td> <td>Fetch the logs of a container</td> </tr> <tr> <td><a href="../container_ls/index">docker container ls</a></td> <td>List containers</td> </tr> <tr> <td><a href="../container_pause/index">docker container pause</a></td> <td>Pause all processes within one or more containers</td> </tr> <tr> <td><a href="../container_port/index">docker container port</a></td> <td>List port mappings or a specific mapping for the container</td> </tr> <tr> <td><a href="../container_prune/index">docker container prune</a></td> <td>Remove all stopped containers</td> </tr> <tr> <td><a href="../container_rename/index">docker container rename</a></td> <td>Rename a container</td> </tr> <tr> <td><a href="../container_restart/index">docker container restart</a></td> <td>Restart one or more containers</td> </tr> <tr> <td><a href="../container_rm/index">docker container rm</a></td> <td>Remove one or more containers</td> </tr> <tr> <td><a href="../container_run/index">docker container run</a></td> <td>Run a command in a new container</td> </tr> <tr> <td><a href="../container_start/index">docker container start</a></td> <td>Start one or more stopped containers</td> </tr> <tr> <td><a href="../container_stats/index">docker container stats</a></td> <td>Display a live stream of container(s) resource usage statistics</td> </tr> <tr> <td><a href="../container_stop/index">docker container stop</a></td> <td>Stop one or more running containers</td> </tr> <tr> <td><a href="../container_top/index">docker container top</a></td> <td>Display the running processes of a container</td> </tr> <tr> <td><a href="../container_unpause/index">docker container unpause</a></td> <td>Unpause all processes within one or more containers</td> </tr> <tr> <td><a href="../container_update/index">docker container update</a></td> <td>Update configuration of one or more containers</td> </tr> <tr> <td><a href="../container_wait/index">docker container wait</a></td> <td>Block until one or more containers stop, then print their exit codes</td> </tr> </tbody> </table> <div class="_attribution">
  <p class="_attribution-p">
    &copy; 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
    <a href="https://docs.docker.com/engine/reference/commandline/container_create/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/container_create/</a>
  </p>
</div>