github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/docs/source/markdown/podman-run.1.md (about) 1 % podman-run(1) 2 3 ## NAME 4 podman\-run - Run a command in a new container 5 6 ## SYNOPSIS 7 **podman run** [*options*] *image* [*command* [*arg* ...]] 8 9 **podman container run** [*options*] *image* [*command* [*arg* ...]] 10 11 ## DESCRIPTION 12 13 Run a process in a new container. **podman run** starts a process with its own 14 file system, its own networking, and its own isolated process tree. The _image_ 15 which starts the process may define defaults related to the process that will be 16 run in the container, the networking to expose, and more, but **podman run** 17 gives final control to the operator or administrator who starts the container 18 from the image. For that reason **podman run** has more options than any other 19 Podman command. 20 21 If the _image_ is not already loaded then **podman run** will pull the _image_, and 22 all image dependencies, from the repository in the same way running **podman 23 pull** _image_ , before it starts the container from that image. 24 25 Several files will be automatically created within the container. These include 26 _/etc/hosts_, _/etc/hostname_, and _/etc/resolv.conf_ to manage networking. 27 These will be based on the host's version of the files, though they can be 28 customized with options (for example, **--dns** will override the host's DNS 29 servers in the created _resolv.conf_). Additionally, a container environment 30 file is created in each container to indicate to programs they are running in a 31 container. This file is located at _/run/.containerenv_. When using the 32 --privileged flag the .containerenv contains name/value pairs indicating the 33 container engine version, whether the engine is running in rootless mode, the 34 container name and id, as well as the image name and id that the container is based on. 35 36 When running from a user defined network namespace, the _/etc/netns/NSNAME/resolv.conf_ 37 will be used if it exists, otherwise _/etc/resolv.conf_ will be used. 38 39 Default settings are defined in `containers.conf`. Most settings for remote 40 connections use the servers containers.conf, except when documented in man 41 pages. 42 43 ## IMAGE 44 45 The image is specified using transport:path format. If no transport is specified, the `docker` (container registry) 46 transport will be used by default. For remote Podman, including Mac and Windows (excluding WSL2) machines, `docker` is the only allowed transport. 47 48 **dir:**_path_ 49 An existing local directory _path_ storing the manifest, layer tarballs and signatures as individual files. This 50 is a non-standardized format, primarily useful for debugging or noninvasive container inspection. 51 52 $ podman save --format docker-dir fedora -o /tmp/fedora 53 $ podman run dir:/tmp/fedora echo hello 54 55 **docker://**_docker-reference_ (Default) 56 An image reference stored in a remote container image registry. Example: "quay.io/podman/stable:latest". 57 The reference can include a path to a specific registry; if it does not, the 58 registries listed in registries.conf will be queried to find a matching image. 59 By default, credentials from `podman login` (stored at 60 $XDG_RUNTIME_DIR/containers/auth.json by default) will be used to authenticate; 61 otherwise it falls back to using credentials in $HOME/.docker/config.json. 62 63 $ podman run registry.fedoraproject.org/fedora:latest echo hello 64 65 **docker-archive:**_path_[**:**_docker-reference_] 66 An image stored in the `docker save` formatted file. _docker-reference_ is only used when creating such a 67 file, and it must not contain a digest. 68 69 $ podman save --format docker-archive fedora -o /tmp/fedora 70 $ podman run docker-archive:/tmp/fedora echo hello 71 72 **docker-daemon:**_docker-reference_ 73 An image in _docker-reference_ format stored in the docker daemon internal storage. The _docker-reference_ can also be an image ID (docker-daemon:algo:digest). 74 75 $ sudo docker pull fedora 76 $ sudo podman run docker-daemon:docker.io/library/fedora echo hello 77 78 **oci-archive:**_path_**:**_tag_ 79 An image in a directory compliant with the "Open Container Image Layout Specification" at the specified _path_ 80 and specified with a _tag_. 81 82 $ podman save --format oci-archive fedora -o /tmp/fedora 83 $ podman run oci-archive:/tmp/fedora echo hello 84 85 ## OPTIONS 86 #### **--add-host**=_host_:_ip_ 87 88 Add a custom host-to-IP mapping (host:ip) 89 90 Add a line to /etc/hosts. The format is hostname:ip. The **--add-host** 91 option can be set multiple times. 92 93 #### **--annotation**=_key_=_value_ 94 95 Add an annotation to the container. 96 This option can be set multiple times. 97 98 #### **--arch**=*ARCH* 99 Override the architecture, defaults to hosts, of the image to be pulled. For example, `arm`. 100 101 #### **--attach**, **-a**=**stdin**|**stdout**|**stderr** 102 103 Attach to STDIN, STDOUT or STDERR. 104 105 In foreground mode (the default when **-d** 106 is not specified), **podman run** can start the process in the container 107 and attach the console to the process's standard input, output, and 108 error. It can even pretend to be a TTY (this is what most commandline 109 executables expect) and pass along signals. The **-a** option can be set for 110 each of **stdin**, **stdout**, and **stderr**. 111 112 #### **--authfile**[=*path*] 113 114 Path to the authentication file. Default is *${XDG_RUNTIME_DIR}/containers/auth.json*. 115 116 Note: You can also override the default path of the authentication file by setting the **REGISTRY_AUTH_FILE** 117 environment variable. 118 119 #### **--blkio-weight**=*weight* 120 121 Block IO relative weight. The _weight_ is a value between **10** and **1000**. 122 123 #### **--blkio-weight-device**=*device*:*weight* 124 125 Block IO relative device weight. 126 127 #### **--cap-add**=*capability* 128 129 Add Linux capabilities. 130 131 #### **--cap-drop**=*capability* 132 133 Drop Linux capabilities. 134 135 #### **--cgroup-conf**=*KEY=VALUE* 136 137 When running on cgroup v2, specify the cgroup file to write to and its value. For example **--cgroup-conf=memory.high=1073741824** sets the memory.high limit to 1GB. 138 139 #### **--cgroup-parent**=*path* 140 141 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. 142 143 #### **--cgroupns**=*mode* 144 145 Set the cgroup namespace mode for the container. 146 147 - **host**: use the host's cgroup namespace inside the container. 148 - **container:**_id_: join the namespace of the specified container. 149 - **private**: create a new cgroup namespace. 150 - **ns:**_path_: join the namespace at the specified path. 151 152 If the host uses cgroups v1, the default is set to **host**. On cgroups v2, the default is **private**. 153 154 #### **--cgroups**=**enabled**|**disabled**|**no-conmon**|**split** 155 156 Determines whether the container will create CGroups. 157 158 Default is **enabled**. 159 160 The **enabled** option will create a new cgroup under the cgroup-parent. 161 The **disabled** option will force the container to not create CGroups, and thus conflicts with CGroup options (**--cgroupns** and **--cgroup-parent**). 162 The **no-conmon** option disables a new CGroup only for the **conmon** process. 163 The **split** option splits the current CGroup in two sub-cgroups: one for conmon and one for the container payload. It is not possible to set **--cgroup-parent** with **split**. 164 165 #### **--chrootdirs**=*path* 166 167 Path to a directory inside the container that should be treated as a `chroot` directory. 168 Any Podman managed file (e.g., /etc/resolv.conf, /etc/hosts, etc/hostname) that is mounted into the root directory will be mounted into that location as well. 169 Multiple directories should be separated with a comma. 170 171 #### **--cidfile**=*file* 172 173 Write the container ID to *file*. 174 175 #### **--conmon-pidfile**=*file* 176 177 Write the pid of the **conmon** process to a file. As **conmon** runs in a separate process than Podman, this is necessary when using systemd to restart Podman containers. 178 (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 179 180 #### **--cpu-period**=*limit* 181 182 Set the CPU period for the Completely Fair Scheduler (CFS), which is a 183 duration in microseconds. Once the container's CPU quota is used up, it will 184 not be scheduled to run until the current period ends. Defaults to 100000 185 microseconds. 186 187 On some systems, changing the CPU limits may not be allowed for non-root 188 users. For more details, see 189 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error 190 191 #### **--cpu-quota**=*limit* 192 193 Limit the CPU Completely Fair Scheduler (CFS) quota. 194 195 Limit the container's CPU usage. By default, containers run with the full 196 CPU resource. The limit is a number in microseconds. If you provide a number, 197 the container will be allowed to use that much CPU time until the CPU period 198 ends (controllable via **--cpu-period**). 199 200 On some systems, changing the CPU limits may not be allowed for non-root 201 users. For more details, see 202 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error 203 204 #### **--cpu-rt-period**=*microseconds* 205 206 Limit the CPU real-time period in microseconds. 207 208 Limit the container's Real Time CPU usage. This flag tell the kernel to restrict the container's Real Time CPU usage to the period you specify. 209 210 This flag is not supported on cgroups V2 systems. 211 212 #### **--cpu-rt-runtime**=*microseconds* 213 214 Limit the CPU real-time runtime in microseconds. 215 216 Limit the containers Real Time CPU usage. This flag tells the kernel to limit the amount of time in a given CPU period Real Time tasks may consume. Ex: 217 Period of 1,000,000us and Runtime of 950,000us means that this container could consume 95% of available CPU and leave the remaining 5% to normal priority tasks. 218 219 The sum of all runtimes across containers cannot exceed the amount allotted to the parent cgroup. 220 221 This flag is not supported on cgroups V2 systems. 222 223 #### **--cpu-shares**=*shares* 224 225 CPU shares (relative weight). 226 227 By default, all containers get the same proportion of CPU cycles. This proportion 228 can be modified by changing the container's CPU share weighting relative 229 to the combined weight of all the running containers. Default weight is **1024**. 230 231 The proportion will only apply when CPU-intensive processes are running. 232 When tasks in one container are idle, other containers can use the 233 left-over CPU time. The actual amount of CPU time will vary depending on 234 the number of containers running on the system. 235 236 For example, consider three containers, one has a cpu-share of 1024 and 237 two others have a cpu-share setting of 512. When processes in all three 238 containers attempt to use 100% of CPU, the first container would receive 239 50% of the total CPU time. If you add a fourth container with a cpu-share 240 of 1024, the first container only gets 33% of the CPU. The remaining containers 241 receive 16.5%, 16.5% and 33% of the CPU. 242 243 On a multi-core system, the shares of CPU time are distributed over all CPU 244 cores. Even if a container is limited to less than 100% of CPU time, it can 245 use 100% of each individual CPU core. 246 247 For example, consider a system with more than three cores. If you start one 248 container **{C0}** with **--cpu-shares=512** running one process, and another container 249 **{C1}** with **--cpu-shares=1024** running two processes, this can result in the following 250 division of CPU shares: 251 252 | PID | container | CPU | CPU share | 253 | ---- | ----------- | ------- | ------------ | 254 | 100 | {C0} | 0 | 100% of CPU0 | 255 | 101 | {C1} | 1 | 100% of CPU1 | 256 | 102 | {C1} | 2 | 100% of CPU2 | 257 258 #### **--cpus**=*number* 259 260 Number of CPUs. The default is *0.0* which means no limit. This is shorthand 261 for **--cpu-period** and **--cpu-quota**, so you may only set either 262 #### **--cpus** or **--cpu-period** and **--cpu-quota**. 263 264 On some systems, changing the CPU limits may not be allowed for non-root 265 users. For more details, see 266 https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error 267 268 #### **--cpuset-cpus**=*number* 269 270 CPUs in which to allow execution. Can be specified as a comma-separated list 271 (e.g. **0,1**), as a range (e.g. **0-3**), or any combination thereof 272 (e.g. **0-3,7,11-15**). 273 274 #### **--cpuset-mems**=*nodes* 275 276 Memory nodes (MEMs) in which to allow execution. Only effective on NUMA systems. 277 278 For example, if you have four memory nodes (0-3) on your system, use **--cpuset-mems=0,1** 279 to only use memory from the first two memory nodes. 280 281 #### **--detach**, **-d** 282 283 Detached mode: run the container in the background and print the new container ID. The default is *false*. 284 285 At any time you can run **podman ps** in 286 the other shell to view a list of the running containers. You can reattach to a 287 detached container with **podman attach**. 288 289 When attached in the tty mode, you can detach from the container (and leave it 290 running) using a configurable key sequence. The default sequence is `ctrl-p,ctrl-q`. 291 Configure the keys sequence using the **--detach-keys** option, or specifying 292 it in the **containers.conf** file: see **containers.conf(5)** for more information. 293 294 #### **--detach-keys**=*sequence* 295 296 Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will set the sequence to the default value of *ctrl-p,ctrl-q*. 297 298 This option can also be set in **containers.conf**(5) file. 299 300 #### **--device**=_host-device_[**:**_container-device_][**:**_permissions_] 301 302 Add a host device to the container. Optional *permissions* parameter 303 can be used to specify device permissions, it is combination of 304 **r** for read, **w** for write, and **m** for **mknod**(2). 305 306 Example: **--device=/dev/sdc:/dev/xvdc:rwm**. 307 308 Note: if _host_device_ is a symbolic link then it will be resolved first. 309 The container will only store the major and minor numbers of the host device. 310 311 Note: if the user only has access rights via a group, accessing the device 312 from inside a rootless container will fail. Use the `--group-add keep-groups` 313 flag to pass the user's supplementary group access into the container. 314 315 Podman may load kernel modules required for using the specified 316 device. The devices that Podman will load modules when necessary are: 317 /dev/fuse. 318 319 #### **--device-cgroup-rule**=rule 320 321 Add a rule to the cgroup allowed devices list 322 323 #### **--device-read-bps**=_path_:_rate_ 324 325 Limit read rate (in bytes per second) from a device (e.g. **--device-read-bps=/dev/sda:1mb**). 326 327 #### **--device-read-iops**=_path_:_rate_ 328 329 Limit read rate (in IO operations per second) from a device (e.g. **--device-read-iops=/dev/sda:1000**). 330 331 #### **--device-write-bps**=_path_:_rate_ 332 333 Limit write rate (in bytes per second) to a device (e.g. **--device-write-bps=/dev/sda:1mb**). 334 335 #### **--device-write-iops**=_path_:_rate_ 336 337 Limit write rate (in IO operations per second) to a device (e.g. **--device-write-iops=/dev/sda:1000**). 338 339 #### **--disable-content-trust** 340 341 This is a Docker specific option to disable image verification to a Docker 342 registry and is not supported by Podman. This flag is a NOOP and provided 343 solely for scripting compatibility. 344 345 #### **--dns**=*ipaddr* 346 347 Set custom DNS servers. Invalid if using **--dns** with **--network** that is set to **none** or **container:**_id_. 348 349 This option can be used to override the DNS 350 configuration passed to the container. Typically this is necessary when the 351 host DNS configuration is invalid for the container (e.g., **127.0.0.1**). When this 352 is the case the **--dns** flag is necessary for every run. 353 354 The special value **none** can be specified to disable creation of _/etc/resolv.conf_ in the container by Podman. 355 The _/etc/resolv.conf_ file in the image will be used without changes. 356 357 #### **--dns-opt**=*option* 358 359 Set custom DNS options. Invalid if using **--dns-opt** with **--network** that is set to **none** or **container:**_id_. 360 361 #### **--dns-search**=*domain* 362 363 Set custom DNS search domains. Invalid if using **--dns-search** and **--network** that is set to **none** or **container:**_id_. 364 Use **--dns-search=.** if you don't wish to set the search domain. 365 366 #### **--entrypoint**=*"command"* | *'["command", "arg1", ...]'* 367 368 Overwrite the default ENTRYPOINT of the image. 369 370 This option allows you to overwrite the default entrypoint of the image. 371 372 The ENTRYPOINT of an image is similar to a COMMAND 373 because it specifies what executable to run when the container starts, but it is 374 (purposely) more difficult to override. The ENTRYPOINT gives a container its 375 default nature or behavior, so that when you set an ENTRYPOINT you can run the 376 container as if it were that binary, complete with default options, and you can 377 pass in more options via the COMMAND. But, sometimes an operator may want to run 378 something else inside the container, so you can override the default ENTRYPOINT 379 at runtime by using a **--entrypoint** and a string to specify the new 380 ENTRYPOINT. 381 382 You need to specify multi option commands in the form of a json string. 383 384 #### **--env**, **-e**=*env* 385 386 Set environment variables. 387 388 This option allows arbitrary environment variables that are available for the process to be launched inside of the container. If an environment variable is specified without a value, Podman will check the host environment for a value and set the variable only if it is set on the host. If an environment variable ending in __*__ is specified, Podman will search the host environment for variables starting with the prefix and will add those variables to the container. If an environment variable with a trailing __*__ is specified, then a value must be supplied. 389 390 See [**Environment**](#environment) note below for precedence and examples. 391 392 #### **--env-file**=*file* 393 394 Read in a line delimited file of environment variables. See **Environment** note below for precedence. 395 396 #### **--env-host** 397 398 Use host environment inside of the container. See **Environment** note below for precedence. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 399 400 #### **--expose**=*port* 401 402 Expose a port, or a range of ports (e.g. **--expose=3300-3310**) to set up port redirection 403 on the host system. 404 405 #### **--gidmap**=*container_gid*:*host_gid*:*amount* 406 407 Run the container in a new user namespace using the supplied mapping. This option conflicts with the **--userns** and **--subgidname** flags. 408 This option can be passed several times to map different ranges. If calling **podman run** as an unprivileged user, the user needs to have the right to use the mapping. See **subuid**(5). 409 The example maps gids **0-1999** in the container to the gids **30000-31999** on the host: **--gidmap=0:30000:2000**. 410 411 **Important note:** The new user namespace mapping based on **--gidmap** is based on the initial mapping made in the _/etc/subgid_ file. 412 Assuming there is a _/etc/subgid_ mapping **groupname:100000:65536**, then **groupname** is initially mapped to a namespace starting with 413 gid **100000** for **65536** ids. From here the **--gidmap** mapping to the new namespace starts from **0** again, but is based on the initial mapping. 414 Meaning **groupname** is initially mapped to gid **100000** which is referenced as **0** in the following **--gidmap** mapping. In terms of the example 415 above: The group **groupname** is mapped to group **100000** of the initial namespace then the 416 **30000**st id of this namespace (which is gid 130000 in this namespace) is mapped to container namespace group id **0**. (groupname -> 100000 / 30000 -> 0) 417 418 Note: the **--gidmap** flag cannot be called in conjunction with the **--pod** flag as a gidmap cannot be set on the container level when in a pod. 419 420 #### **--group-add**=*group|keep-groups* 421 422 Assign additional groups to the primary user running within the container process. 423 424 - `keep-groups` is a special flag that tells Podman to keep the supplementary group access. 425 426 Allows container to use the user's supplementary group access. If file systems or 427 devices are only accessible by the rootless user's group, this flag tells the OCI 428 runtime to pass the group access into the container. Currently only available 429 with the `crun` OCI runtime. Note: `keep-groups` is exclusive, you cannot add any other groups 430 with this flag. (Not available for remote commands, including Mac and Windows (excluding WSL2) machines) 431 432 #### **--health-cmd**=*"command"* | *'["command", "arg1", ...]'* 433 434 Set or alter a healthcheck command for a container. The command is a command to be executed inside your 435 container that determines your container health. The command is required for other healthcheck options 436 to be applied. A value of **none** disables existing healthchecks. 437 438 Multiple options can be passed in the form of a JSON array; otherwise, the command will be interpreted 439 as an argument to **/bin/sh -c**. 440 441 #### **--health-interval**=*interval* 442 443 Set an interval for the healthchecks. An _interval_ of **disable** results in no automatic timer setup. The default is **30s**. 444 445 #### **--health-retries**=*retries* 446 447 The number of retries allowed before a healthcheck is considered to be unhealthy. The default value is **3**. 448 449 #### **--health-start-period**=*period* 450 451 The initialization time needed for a container to bootstrap. The value can be expressed in time format like 452 **2m3s**. The default value is **0s**. 453 454 #### **--health-timeout**=*timeout* 455 456 The maximum time allowed to complete the healthcheck before an interval is considered failed. Like start-period, the 457 value can be expressed in a time format such as **1m22s**. The default value is **30s**. 458 459 #### **--help** 460 461 Print usage statement 462 463 #### **--hostname**=*name*, **-h** 464 465 Container host name 466 467 Sets the container host name that is available inside the container. Can only be used with a private UTS namespace `--uts=private` (default). If `--pod` is specified and the pod shares the UTS namespace (default) the pod's hostname will be used. 468 469 #### **--hostuser**=*name* 470 471 Add a user account to /etc/passwd from the host to the container. The Username 472 or UID must exist on the host system. 473 474 #### **--http-proxy** 475 476 By default proxy environment variables are passed into the container if set 477 for the Podman process. This can be disabled by setting the value to **false**. 478 The environment variables passed in include **http_proxy**, 479 **https_proxy**, **ftp_proxy**, **no_proxy**, and also the upper case versions of 480 those. This option is only needed when the host system must use a proxy but 481 the container should not use any proxy. Proxy environment variables specified 482 for the container in any other way will override the values that would have 483 been passed through from the host. (Other ways to specify the proxy for the 484 container include passing the values with the **--env** flag, or hard coding the 485 proxy environment at container build time.) (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 486 487 Defaults to **true**. 488 489 #### **--image-volume**, **builtin-volume**=**bind**|**tmpfs**|**ignore** 490 491 Tells Podman how to handle the builtin image volumes. Default is **bind**. 492 493 - **bind**: An anonymous named volume will be created and mounted into the container. 494 - **tmpfs**: The volume is mounted onto the container as a tmpfs, which allows the users to create 495 content that disappears when the container is stopped. 496 - **ignore**: All volumes are just ignored and no action is taken. 497 498 #### **--init** 499 500 Run an init inside the container that forwards signals and reaps processes. 501 The container-init binary is mounted at `/run/podman-init`. 502 Mounting over `/run` will hence break container execution. 503 504 #### **--init-path**=*path* 505 506 Path to the container-init binary. 507 508 #### **--interactive**, **-i** 509 510 When set to **true**, keep stdin open even if not attached. The default is **false**. 511 512 #### **--ip**=*ipv4* 513 514 Specify a static IPv4 address for the container, for example **10.88.64.128**. 515 This option can only be used if the container is joined to only a single network - i.e., **--network=network-name** is used at most once - 516 and if the container is not joining another container's network namespace via **--network=container:_id_**. 517 The address must be within the network's IP address pool (default **10.88.0.0/16**). 518 519 To specify multiple static IP addresses per container, set multiple networks using the **--network** option with a static IP address specified for each using the `ip` mode for that option. 520 521 #### **--ip6**=*ipv6* 522 523 Specify a static IPv6 address for the container, for example **fd46:db93:aa76:ac37::10**. 524 This option can only be used if the container is joined to only a single network - i.e., **--network=network-name** is used at most once - 525 and if the container is not joining another container's network namespace via **--network=container:_id_**. 526 The address must be within the network's IPv6 address pool. 527 528 To specify multiple static IPv6 addresses per container, set multiple networks using the **--network** option with a static IPv6 address specified for each using the `ip6` mode for that option. 529 530 #### **--ipc**=*mode* 531 532 Set the IPC namespace mode for a container. The default is to create 533 a private IPC namespace. 534 535 - "": Use Podman's default, defined in containers.conf. 536 - **container:**_id_: reuses another container shared memory, semaphores and message queues 537 - **host**: use the host shared memory,semaphores and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure. 538 - **none**: private IPC namespace, with /dev/shm not mounted. 539 - **ns:**_path_: path to an IPC namespace to join. 540 - **private**: private IPC namespace. 541 = **shareable**: private IPC namespace with a possibility to share it with other containers. 542 543 #### **--label**, **-l**=*key*=*value* 544 545 Add metadata to a container. 546 547 #### **--label-file**=*file* 548 549 Read in a line-delimited file of labels. 550 551 #### **--link-local-ip**=*ip* 552 553 Not implemented. 554 555 #### **--log-driver**="*driver*" 556 557 Logging driver for the container. Currently available options are **k8s-file**, **journald**, **none** and **passthrough**, with **json-file** aliased to **k8s-file** for scripting compatibility. (Default journald) 558 559 The podman info command below will display the default log-driver for the system. 560 ``` 561 $ podman info --format '{{ .Host.LogDriver }}' 562 journald 563 ``` 564 The **passthrough** driver passes down the standard streams (stdin, stdout, stderr) to the 565 container. It is not allowed with the remote Podman client, including Mac and Windows (excluding WSL2) machines, and on a tty, since it is 566 vulnerable to attacks via TIOCSTI. 567 568 569 #### **--log-opt**=*name*=*value* 570 571 Logging driver specific options. 572 573 Set custom logging configuration. The following *name*s are supported: 574 575 **path**: specify a path to the log file 576 (e.g. **--log-opt path=/var/log/container/mycontainer.json**); 577 578 **max-size**: specify a max size of the log file 579 (e.g. **--log-opt max-size=10mb**); 580 581 **tag**: specify a custom log tag for the container 582 (e.g. **--log-opt tag="{{.ImageName}}"**. 583 584 This option is currently supported only by the **journald** log driver. 585 586 #### **--mac-address**=*address* 587 588 Container network interface MAC address (e.g. 92:d0:c6:0a:29:33) 589 This option can only be used if the container is joined to only a single network - i.e., **--network=_network-name_** is used at most once - 590 and if the container is not joining another container's network namespace via **--network=container:_id_**. 591 592 Remember that the MAC address in an Ethernet network must be unique. 593 The IPv6 link-local address will be based on the device's MAC address 594 according to RFC4862. 595 596 To specify multiple static MAC addresses per container, set multiple networks using the **--network** option with a static MAC address specified for each using the `mac` mode for that option. 597 598 #### **--memory**, **-m**=_number_[_unit_] 599 600 Memory limit. A _unit_ can be **b** (bytes), **k** (kibibytes), **m** (mebibytes), or **g** (gibibytes). 601 602 Allows you to constrain the memory available to a container. If the host 603 supports swap memory, then the **-m** memory setting can be larger than physical 604 RAM. If a limit of 0 is specified (not using **-m**), the container's memory is 605 not limited. The actual limit may be rounded up to a multiple of the operating 606 system's page size (the value would be very large, that's millions of trillions). 607 608 #### **--memory-reservation**=_number_[_unit_] 609 610 Memory soft limit. A _unit_ can be **b** (bytes), **k** (kibibytes), **m** (mebibytes), or **g** (gibibytes). 611 612 After setting memory reservation, when the system detects memory contention 613 or low memory, containers are forced to restrict their consumption to their 614 reservation. So you should always set the value below **--memory**, otherwise the 615 hard limit will take precedence. By default, memory reservation will be the same 616 as memory limit. 617 618 #### **--memory-swap**=_number_[_unit_] 619 620 A limit value equal to memory plus swap. 621 A _unit_ can be **b** (bytes), **k** (kibibytes), **m** (mebibytes), or **g** (gibibytes). 622 623 Must be used with the **-m** (**--memory**) flag. 624 The argument value should always be larger than that of 625 **-m** (**--memory**) By default, it is set to double 626 the value of **--memory**. 627 628 Set _number_ to **-1** to enable unlimited swap. 629 630 #### **--memory-swappiness**=*number* 631 632 Tune a container's memory swappiness behavior. Accepts an integer between *0* and *100*. 633 634 This flag is not supported on cgroups V2 systems. 635 636 #### **--mount**=*type=TYPE,TYPE-SPECIFIC-OPTION[,...]* 637 638 Attach a filesystem mount to the container 639 640 Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and **devpts**. <sup>[[1]](#Footnote1)</sup> 641 642 e.g. 643 644 type=bind,source=/path/on/host,destination=/path/in/container 645 646 type=bind,src=/path/on/host,dst=/path/in/container,relabel=shared 647 648 type=bind,src=/path/on/host,dst=/path/in/container,relabel=shared,U=true 649 650 type=volume,source=vol1,destination=/path/in/container,ro=true 651 652 type=tmpfs,tmpfs-size=512M,destination=/path/in/container 653 654 type=image,source=fedora,destination=/fedora-image,rw=true 655 656 type=devpts,destination=/dev/pts 657 658 Common Options: 659 660 · src, source: mount source spec for bind and volume. Mandatory for bind. 661 662 · dst, destination, target: mount destination spec. 663 664 Options specific to volume: 665 666 · ro, readonly: true or false (default). 667 668 . U, chown: true or false (default). Change recursively the owner and group of the source volume based on the UID and GID of the container. 669 670 · idmap: true or false (default). If specified, create an idmapped mount to the target user namespace in the container. 671 672 Options specific to image: 673 674 · rw, readwrite: true or false (default). 675 676 Options specific to bind: 677 678 · ro, readonly: true or false (default). 679 680 · bind-propagation: shared, slave, private, unbindable, rshared, rslave, runbindable, or rprivate(default). See also mount(2). 681 682 . bind-nonrecursive: do not setup a recursive bind mount. By default it is recursive. 683 684 . relabel: shared, private. 685 686 · idmap: true or false (default). If specified, create an idmapped mount to the target user namespace in the container. 687 688 . U, chown: true or false (default). Change recursively the owner and group of the source volume based on the UID and GID of the container. 689 690 Options specific to tmpfs: 691 692 · ro, readonly: true or false (default). 693 694 · tmpfs-size: Size of the tmpfs mount in bytes. Unlimited by default in Linux. 695 696 · tmpfs-mode: File mode of the tmpfs in octal. (e.g. 700 or 0700.) Defaults to 1777 in Linux. 697 698 · tmpcopyup: Enable copyup from the image directory at the same location to the tmpfs. Used by default. 699 700 · notmpcopyup: Disable copying files from the image to the tmpfs. 701 702 . U, chown: true or false (default). Change recursively the owner and group of the source volume based on the UID and GID of the container. 703 704 Options specific to devpts: 705 706 · uid: UID of the file owner (default 0). 707 708 · gid: GID of the file owner (default 0). 709 710 · mode: permission mask for the file (default 600). 711 712 · max: maximum number of PTYs (default 1048576). 713 714 #### **--name**=*name* 715 716 Assign a name to the container. 717 718 The operator can identify a container in three ways: 719 720 - UUID long identifier (“f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778”); 721 - UUID short identifier (“f78375b1c487”); 722 - Name (“jonah”). 723 724 Podman generates a UUID for each container, and if a name is not assigned 725 to the container with **--name** then it will generate a random 726 string name. The name is useful any place you need to identify a container. 727 This works for both background and foreground containers. 728 729 #### **--network**=*mode*, **--net** 730 731 Set the network mode for the container. Invalid if using **--dns**, **--dns-opt**, or **--dns-search** with **--network** set to **none** or **container:**_id_. If used together with **--pod**, the container will not join the pod's network namespace. 732 733 Valid _mode_ values are: 734 735 - **bridge[:OPTIONS,...]**: Create a network stack on the default bridge. This is the default for rootful containers. It is possible to specify these additional options: 736 - **alias=name**: Add network-scoped alias for the container. 737 - **ip=IPv4**: Specify a static ipv4 address for this container. 738 - **ip=IPv6**: Specify a static ipv6 address for this container. 739 - **mac=MAC**: Specify a static mac address for this container. 740 - **interface_name**: Specify a name for the created network interface inside the container. 741 742 For example to set a static ipv4 address and a static mac address, use `--network bridge:ip=10.88.0.10,mac=44:33:22:11:00:99`. 743 - \<network name or ID\>[:OPTIONS,...]: Connect to a user-defined network; this is the network name or ID from a network created by **[podman network create](podman-network-create.1.md)**. Using the network name implies the bridge network mode. It is possible to specify the same options described under the bridge mode above. You can use the **--network** option multiple times to specify additional networks. 744 - **none**: Create a network namespace for the container but do not configure network interfaces for it, thus the container has no network connectivity. 745 - **container:**_id_: Reuse another container's network stack. 746 - **host**: Do not create a network namespace, the container will use the host's network. Note: The host mode gives the container full access to local system services such as D-bus and is therefore considered insecure. 747 - **ns:**_path_: Path to a network namespace to join. 748 - **private**: Create a new namespace for the container. This will use the **bridge** mode for rootful containers and **slirp4netns** for rootless ones. 749 - **slirp4netns[:OPTIONS,...]**: use **slirp4netns**(1) to create a user network stack. This is the default for rootless containers. It is possible to specify these additional options, they can also be set with `network_cmd_options` in containers.conf: 750 - **allow_host_loopback=true|false**: Allow the slirp4netns to reach the host loopback IP (`10.0.2.2`). Default is false. 751 - **mtu=MTU**: Specify the MTU to use for this network. (Default is `65520`). 752 - **cidr=CIDR**: Specify ip range to use for this network. (Default is `10.0.2.0/24`). 753 - **enable_ipv6=true|false**: Enable IPv6. Default is true. (Required for `outbound_addr6`). 754 - **outbound_addr=INTERFACE**: Specify the outbound interface slirp should bind to (ipv4 traffic only). 755 - **outbound_addr=IPv4**: Specify the outbound ipv4 address slirp should bind to. 756 - **outbound_addr6=INTERFACE**: Specify the outbound interface slirp should bind to (ipv6 traffic only). 757 - **outbound_addr6=IPv6**: Specify the outbound ipv6 address slirp should bind to. 758 - **port_handler=rootlesskit**: Use rootlesskit for port forwarding. Default. 759 Note: Rootlesskit changes the source IP address of incoming packets to an IP address in the container network namespace, usually `10.0.2.100`. If your application requires the real source IP address, e.g. web server logs, use the slirp4netns port handler. The rootlesskit port handler is also used for rootless containers when connected to user-defined networks. 760 - **port_handler=slirp4netns**: Use the slirp4netns port forwarding, it is slower than rootlesskit but preserves the correct source IP address. This port handler cannot be used for user-defined networks. 761 762 #### **--network-alias**=*alias* 763 764 Add a network-scoped alias for the container, setting the alias for all networks that the container joins. To set a name only for a specific network, use the alias option as described under the **--network** option. 765 Network aliases work only with the bridge networking mode. This option can be specified multiple times. 766 NOTE: A container will only have access to aliases on the first network that it joins. This is a limitation that will be removed in a later release. 767 768 #### **--no-healthcheck** 769 770 Disable any defined healthchecks for container. 771 772 #### **--no-hosts** 773 774 Do not create _/etc/hosts_ for the container. 775 By default, Podman will manage _/etc/hosts_, adding the container's own IP address and any hosts from **--add-host**. 776 **--no-hosts** disables this, and the image's _/etc/hosts_ will be preserved unmodified. 777 This option conflicts with **--add-host**. 778 779 #### **--oom-kill-disable** 780 781 Whether to disable OOM Killer for the container or not. 782 783 This flag is not supported on cgroups V2 systems. 784 785 #### **--oom-score-adj**=*num* 786 787 Tune the host's OOM preferences for containers (accepts values from **-1000** to **1000**). 788 789 #### **--os**=*OS* 790 Override the OS, defaults to hosts, of the image to be pulled. For example, `windows`. 791 792 #### **--passwd** 793 794 Allow Podman to add entries to /etc/passwd and /etc/group when used in conjunction with the --user option. 795 This is used to override the Podman provided user setup in favor of entrypoint configurations such as libnss-extrausers. 796 797 #### **--passwd-entry**=*ENTRY* 798 799 Customize the entry that is written to the `/etc/passwd` file within the container when `--passwd` is used. 800 801 The variables $USERNAME, $UID, $GID, $NAME, $HOME are automatically replaced with their value at runtime. 802 803 #### **--personality**=*persona* 804 805 Personality sets the execution domain via Linux personality(2). 806 807 #### **--pid**=*mode* 808 809 Set the PID namespace mode for the container. 810 The default is to create a private PID namespace for the container. 811 812 - **container:**_id_: join another container's PID namespace; 813 - **host**: use the host's PID namespace for the container. Note the host mode gives the container full access to local PID and is therefore considered insecure; 814 - **private**: create a new namespace for the container (default) 815 - **ns:**_path_: join the specified PID namespace. 816 817 #### **--pidfile**=*path* 818 819 When the pidfile location is specified, the container process' PID will be written to the pidfile. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 820 If the pidfile option is not specified, the container process' PID will be written to /run/containers/storage/${storage-driver}-containers/$CID/userdata/pidfile. 821 822 After the container is started, the location for the pidfile can be discovered with the following `podman inspect` command: 823 824 $ podman inspect --format '{{ .PidFile }}' $CID 825 /run/containers/storage/${storage-driver}-containers/$CID/userdata/pidfile 826 827 #### **--pids-limit**=*limit* 828 829 Tune the container's pids limit. Set to **-1** to have unlimited pids for the container. The default is **4096** on systems that support "pids" cgroup controller. 830 831 #### **--platform**=*OS/ARCH* 832 833 Specify the platform for selecting the image. (Conflicts with --arch and --os) 834 The `--platform` option can be used to override the current architecture and operating system. 835 836 #### **--pod**=*name* 837 838 Run container in an existing pod. If you want Podman to make the pod for you, prefix the pod name with **new:**. 839 To make a pod with more granular options, use the **podman pod create** command before creating a container. 840 If a container is run with a pod, and the pod has an infra-container, the infra-container will be started before the container is. 841 842 #### **--pod-id-file**=*path* 843 844 Run container in an existing pod and read the pod's ID from the specified file. 845 If a container is run within a pod, and the pod has an infra-container, the infra-container will be started before the container is. 846 847 #### **--preserve-fds**=*N* 848 849 Pass down to the process N additional file descriptors (in addition to 0, 1, 2). 850 The total FDs will be 3+N. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 851 852 #### **--privileged** 853 854 Give extended privileges to this container. The default is **false**. 855 856 By default, Podman containers are unprivileged (**=false**) and cannot, for 857 example, modify parts of the operating system. This is because by default a 858 container is only allowed limited access to devices. A "privileged" container 859 is given the same access to devices as the user launching the container. 860 861 A privileged container turns off the security features that isolate the 862 container from the host. Dropped Capabilities, limited devices, read-only mount 863 points, Apparmor/SELinux separation, and Seccomp filters are all disabled. 864 865 Rootless containers cannot have more privileges than the account that launched them. 866 867 #### **--publish**, **-p**=[[_ip_:][_hostPort_]:]_containerPort_[/_protocol_] 868 869 Publish a container's port, or range of ports, to the host. 870 871 Both hostPort and containerPort can be specified as a range of ports. 872 When specifying ranges for both, the number of container ports in the 873 range must match the number of host ports in the range. 874 875 If host IP is set to 0.0.0.0 or not set at all, the port will be bound on all IPs on the host. 876 877 By default, Podman will publish TCP ports. To publish a UDP port instead, give 878 `udp` as protocol. To publish both TCP and UDP ports, set `--publish` twice, 879 with `tcp`, and `udp` as protocols respectively. Rootful containers can also 880 publish ports using the `sctp` protocol. 881 882 Host port does not have to be specified (e.g. `podman run -p 127.0.0.1::80`). 883 If it is not, the container port will be randomly assigned a port on the host. 884 885 Use **podman port** to see the actual mapping: `podman port $CONTAINER $CONTAINERPORT`. 886 887 **Note:** If a container will be run within a pod, it is not necessary to publish the port for 888 the containers in the pod. The port must only be published by the pod itself. Pod network 889 stacks act like the network stack on the host - you have a variety of containers in the pod, 890 and programs in the container, all sharing a single interface and IP address, and 891 associated ports. If one container binds to a port, no other container can use that port 892 within the pod while it is in use. Containers in the pod can also communicate over localhost 893 by having one container bind to localhost in the pod, and another connect to that port. 894 895 #### **--publish-all**, **-P** 896 897 Publish all exposed ports to random ports on the host interfaces. The default is **false**. 898 899 When set to **true**, publish all exposed ports to the host interfaces. The 900 default is **false**. If the operator uses **-P** (or **-p**) then Podman will make the 901 exposed port accessible on the host and the ports will be available to any 902 client that can reach the host. 903 904 When using this option, Podman will bind any exposed port to a random port on the host 905 within an ephemeral port range defined by */proc/sys/net/ipv4/ip_local_port_range*. 906 To find the mapping between the host ports and the exposed ports, use **podman port**. 907 908 #### **--pull**=**always**|**missing**|**never** 909 910 Pull image before running. The default is **missing**. 911 912 - **missing**: attempt to pull the latest image from the registries listed in registries.conf if a local image does not exist.Raise an error if the image is not in any listed registry and is not present locally. 913 - **always**: Pull the image from the first registry it is found in as listed in registries.conf. Raise an error if not found in the registries, even if the image is present locally. 914 - **never**: do not pull the image from the registry, use only the local version. Raise an error if the image is not present locally. 915 916 #### **--quiet**, **-q** 917 918 Suppress output information when pulling images 919 920 #### **--read-only** 921 922 Mount the container's root filesystem as read only. 923 924 By default a container will have its root filesystem writable allowing processes 925 to write files anywhere. By specifying the **--read-only** flag, the container will have 926 its root filesystem mounted as read only prohibiting any writes. 927 928 #### **--read-only-tmpfs** 929 930 If container is running in **--read-only** mode, then mount a read-write tmpfs on _/run_, _/tmp_, and _/var/tmp_. The default is **true**. 931 932 #### **--replace** 933 934 If another container with the same name already exists, replace and remove it. The default is **false**. 935 936 #### **--requires**=**container** 937 938 Specify one or more requirements. 939 A requirement is a dependency container that will be started before this container. 940 Containers can be specified by name or ID, with multiple containers being separated by commas. 941 942 #### **--restart**=*policy* 943 944 Restart policy to follow when containers exit. 945 Restart policy will not take effect if a container is stopped via the **podman kill** or **podman stop** commands. 946 947 Valid _policy_ values are: 948 949 - `no` : Do not restart containers on exit 950 - `on-failure[:max_retries]` : Restart containers when they exit with a non-zero exit code, retrying indefinitely or until the optional *max_retries* count is hit 951 - `always` : Restart containers when they exit, regardless of status, retrying indefinitely 952 - `unless-stopped` : Identical to **always** 953 954 Please note that restart will not restart containers after a system reboot. 955 If this functionality is required in your environment, you can invoke Podman from a **systemd.unit**(5) file, or create an init script for whichever init system is in use. 956 To generate systemd unit files, please see **podman generate systemd**. 957 958 #### **--rm** 959 960 Automatically remove the container when it exits. The default is **false**. 961 962 #### **--rmi** 963 964 After exit of the container, remove the image unless another 965 container is using it. The default is *false*. 966 967 #### **--rootfs** 968 969 If specified, the first argument refers to an exploded container on the file system. 970 971 This is useful to run a container without requiring any image management, the rootfs 972 of the container is assumed to be managed externally. 973 974 `Overlay Rootfs Mounts` 975 976 The `:O` flag tells Podman to mount the directory from the rootfs path as 977 storage using the `overlay file system`. The container processes 978 can modify content within the mount point which is stored in the 979 container storage in a separate directory. In overlay terms, the source 980 directory will be the lower, and the container storage directory will be the 981 upper. Modifications to the mount point are destroyed when the container 982 finishes executing, similar to a tmpfs mount point being unmounted. 983 984 Note: On **SELinux** systems, the rootfs needs the correct label, which is by default 985 **unconfined_u:object_r:container_file_t**. 986 987 #### **--sdnotify**=**container**|**conmon**|**ignore** 988 989 Determines how to use the NOTIFY_SOCKET, as passed with systemd and Type=notify. 990 991 Default is **container**, which means allow the OCI runtime to proxy the socket into the 992 container to receive ready notification. Podman will set the MAINPID to conmon's pid. 993 The **conmon** option sets MAINPID to conmon's pid, and sends READY when the container 994 has started. The socket is never passed to the runtime or the container. 995 The **ignore** option removes NOTIFY_SOCKET from the environment for itself and child processes, 996 for the case where some other process above Podman uses NOTIFY_SOCKET and Podman should not use it. 997 998 #### **--seccomp-policy**=*policy* 999 1000 Specify the policy to select the seccomp profile. If set to *image*, Podman will look for a "io.containers.seccomp.profile" label in the container-image config and use its value as a seccomp profile. Otherwise, Podman will follow the *default* policy by applying the default profile unless specified otherwise via *--security-opt seccomp* as described below. 1001 1002 Note that this feature is experimental and may change in the future. 1003 1004 #### **--secret**=*secret*[,opt=opt ...] 1005 1006 Give the container access to a secret. Can be specified multiple times. 1007 1008 A secret is a blob of sensitive data which a container needs at runtime but 1009 should not be stored in the image or in source control, such as usernames and passwords, 1010 TLS certificates and keys, SSH keys or other important generic strings or binary content (up to 500 kb in size). 1011 1012 When secrets are specified as type `mount`, the secrets are copied and mounted into the container when a container is created. 1013 When secrets are specified as type `env`, the secret will be set as an environment variable within the container. 1014 Secrets are written in the container at the time of container creation, and modifying the secret using `podman secret` commands 1015 after the container is created will not affect the secret inside the container. 1016 1017 Secrets and its storage are managed using the `podman secret` command. 1018 1019 Secret Options 1020 1021 - `type=mount|env` : How the secret will be exposed to the container. Default mount. 1022 - `target=target` : Target of secret. Defaults to secret name. 1023 - `uid=0` : UID of secret. Defaults to 0. Mount secret type only. 1024 - `gid=0` : GID of secret. Defaults to 0. Mount secret type only. 1025 - `mode=0` : Mode of secret. Defaults to 0444. Mount secret type only. 1026 1027 #### **--security-opt**=*option* 1028 1029 Security Options 1030 1031 - **apparmor=unconfined** : Turn off apparmor confinement for the container 1032 - **apparmor**=_your-profile_ : Set the apparmor confinement profile for the container 1033 1034 - **label=user:**_USER_: Set the label user for the container processes 1035 - **label=role:**_ROLE_: Set the label role for the container processes 1036 - **label=type:**_TYPE_: Set the label process type for the container processes 1037 - **label=level:**_LEVEL_: Set the label level for the container processes 1038 - **label=filetype:**TYPE_: Set the label file type for the container files 1039 - **label=disable**: Turn off label separation for the container 1040 1041 Note: Labeling can be disabled for all containers by setting label=false in the **containers.conf** (`/etc/containers/containers.conf` or `$HOME/.config/containers/containers.conf`) file. 1042 1043 - **mask**=_/path/1:/path/2_: The paths to mask separated by a colon. A masked path 1044 cannot be accessed inside the container. 1045 1046 - **no-new-privileges**: Disable container processes from gaining additional privileges 1047 1048 - **seccomp=unconfined**: Turn off seccomp confinement for the container. 1049 - **seccomp=profile.json**: JSON file to be used as a seccomp filter. Note that the `io.podman.annotations.seccomp` annotation is set with the specified value as shown in `podman inspect`. 1050 1051 - **proc-opts**=_OPTIONS_ : Comma-separated list of options to use for the /proc mount. More details 1052 for the possible mount options are specified in the **proc(5)** man page. 1053 1054 - **unmask**=_ALL_ or _/path/1:/path/2_, or shell expanded paths (/proc/*): Paths to unmask separated by a colon. If set to **ALL**, it will unmask all the paths that are masked or made read only by default. 1055 The default masked paths are **/proc/acpi, /proc/kcore, /proc/keys, /proc/latency_stats, /proc/sched_debug, /proc/scsi, /proc/timer_list, /proc/timer_stats, /sys/firmware, and /sys/fs/selinux.**. The default paths that are read only are **/proc/asound**, **/proc/bus**, **/proc/fs**, **/proc/irq**, **/proc/sys**, **/proc/sysrq-trigger**, **/sys/fs/cgroup**. 1056 1057 Note: Labeling can be disabled for all containers by setting **label=false** in the **containers.conf**(5) file. 1058 1059 #### **--shm-size**=_number_[_unit_] 1060 1061 Size of _/dev/shm_. A _unit_ can be **b** (bytes), **k** (kibibytes), **m** (mebibytes), or **g** (gibibytes). 1062 If you omit the unit, the system uses bytes. If you omit the size entirely, the default is **64m**. 1063 When _size_ is **0**, there is no limit on the amount of memory used for IPC by the container. 1064 1065 #### **--sig-proxy** 1066 1067 Sets whether the signals sent to the **podman run** command are proxied to the container process. SIGCHLD, SIGSTOP, and SIGKILL are not proxied. The default is **true**. 1068 1069 #### **--stop-signal**=*signal* 1070 1071 Signal to stop a container. Default is **SIGTERM**. 1072 1073 #### **--stop-timeout**=*seconds* 1074 1075 Timeout to stop a container. Default is **10**. 1076 Remote connections use local containers.conf for defaults 1077 1078 #### **--subgidname**=*name* 1079 1080 Run the container in a new user namespace using the map with _name_ in the _/etc/subgid_ file. 1081 If calling **podman run** as an unprivileged user, the user needs to have the right to use the mapping. See **subgid**(5). 1082 This flag conflicts with **--userns** and **--gidmap**. 1083 1084 #### **--subuidname**=*name* 1085 1086 Run the container in a new user namespace using the map with _name_ in the _/etc/subuid_ file. 1087 If calling **podman run** as an unprivileged user, the user needs to have the right to use the mapping. See **subuid**(5). 1088 This flag conflicts with **--userns** and **--uidmap**. 1089 1090 #### **--sysctl**=_name_=_value_ 1091 1092 Configure namespaced kernel parameters at runtime. 1093 1094 For the IPC namespace, the following sysctls are allowed: 1095 1096 - kernel.msgmax 1097 - kernel.msgmnb 1098 - kernel.msgmni 1099 - kernel.sem 1100 - kernel.shmall 1101 - kernel.shmmax 1102 - kernel.shmmni 1103 - kernel.shm_rmid_forced 1104 - Sysctls beginning with fs.mqueue.\* 1105 1106 Note: if you use the **--ipc=host** option, the above sysctls will not be allowed. 1107 1108 For the network namespace, the following sysctls are allowed: 1109 1110 - Sysctls beginning with net.\* 1111 1112 Note: if you use the **--network=host** option, these sysctls will not be allowed. 1113 1114 #### **--systemd**=**true**|**false**|**always** 1115 1116 Run container in systemd mode. The default is **true**. 1117 1118 The value *always* enforces the systemd mode is enforced without 1119 looking at the executable name. Otherwise, if set to true and the 1120 command you are running inside the container is **systemd**, **/usr/sbin/init**, 1121 **/sbin/init** or **/usr/local/sbin/init**. 1122 1123 Running the container in systemd mode causes the following changes: 1124 1125 * Podman mounts tmpfs file systems on the following directories 1126 * _/run_ 1127 * _/run/lock_ 1128 * _/tmp_ 1129 * _/sys/fs/cgroup/systemd_ 1130 * _/var/lib/journal_ 1131 * Podman sets the default stop signal to **SIGRTMIN+3**. 1132 * Podman sets **container_uuid** environment variable in the container to the 1133 first 32 characters of the container id. 1134 1135 This allows systemd to run in a confined container without any modifications. 1136 1137 Note that on **SELinux** systems, systemd attempts to write to the cgroup 1138 file system. Containers writing to the cgroup file system are denied by default. 1139 The **container_manage_cgroup** boolean must be enabled for this to be allowed on an SELinux separated system. 1140 ``` 1141 setsebool -P container_manage_cgroup true 1142 ``` 1143 1144 #### **--timeout**=*seconds* 1145 1146 Maximum time a container is allowed to run before conmon sends it the kill 1147 signal. By default containers will run until they exit or are stopped by 1148 `podman stop`. 1149 1150 #### **--tls-verify** 1151 1152 Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified, TLS verification will be used unless the target registry is listed as an insecure registry in registries.conf. 1153 1154 #### **--tmpfs**=*fs* 1155 1156 Create a tmpfs mount. 1157 1158 Mount a temporary filesystem (**tmpfs**) mount into a container, for example: 1159 1160 ``` 1161 $ podman run -d --tmpfs /tmp:rw,size=787448k,mode=1777 my_image 1162 ``` 1163 1164 This command mounts a **tmpfs** at _/tmp_ within the container. The supported mount 1165 options are the same as the Linux default mount flags. If you do not specify 1166 any options, the systems uses the following options: 1167 **rw,noexec,nosuid,nodev**. 1168 1169 #### **--tty**, **-t** 1170 1171 Allocate a pseudo-TTY. The default is **false**. 1172 1173 When set to **true**, Podman will allocate a pseudo-tty and attach to the standard 1174 input of the container. This can be used, for example, to run a throwaway 1175 interactive shell. The default is **false**. 1176 1177 **NOTE**: The --tty flag prevents redirection of standard output. It combines STDOUT and STDERR, it can insert control characters, and it can hang pipes. This option should only be used when run interactively in a terminal. When feeding input to Podman, use -i only, not -it. 1178 1179 ``` 1180 echo "asdf" | podman run --rm -i someimage /bin/cat 1181 ``` 1182 1183 #### **--tz**=*timezone* 1184 1185 Set timezone in container. This flag takes area-based timezones, GMT time, as well as `local`, which sets the timezone in the container to match the host machine. See `/usr/share/zoneinfo/` for valid timezones. 1186 Remote connections use local containers.conf for defaults 1187 1188 #### **--uidmap**=*container_uid*:*from_uid*:*amount* 1189 1190 Run the container in a new user namespace using the supplied mapping. This 1191 option conflicts with the **--userns** and **--subuidname** options. This 1192 option provides a way to map host UIDs to container UIDs. It can be passed 1193 several times to map different ranges. 1194 1195 The _from_uid_ value is based upon the user running the command, either rootful or rootless users. 1196 * rootful user: *container_uid*:*host_uid*:*amount* 1197 * rootless user: *container_uid*:*intermediate_uid*:*amount* 1198 1199 When **podman run** is called by a privileged user, the option **--uidmap** 1200 works as a direct mapping between host UIDs and container UIDs. 1201 1202 host UID -> container UID 1203 1204 The _amount_ specifies the number of consecutive UIDs that will be mapped. 1205 If for example _amount_ is **4** the mapping would look like: 1206 1207 | host UID | container UID | 1208 | - | - | 1209 | _from_uid_ | _container_uid_ | 1210 | _from_uid_ + 1 | _container_uid_ + 1 | 1211 | _from_uid_ + 2 | _container_uid_ + 2 | 1212 | _from_uid_ + 3 | _container_uid_ + 3 | 1213 1214 When **podman run** is called by an unprivileged user (i.e. running rootless), 1215 the value _from_uid_ is interpreted as an "intermediate UID". In the rootless 1216 case, host UIDs are not mapped directly to container UIDs. Instead the mapping 1217 happens over two mapping steps: 1218 1219 host UID -> intermediate UID -> container UID 1220 1221 The **--uidmap** option only influences the second mapping step. 1222 1223 The first mapping step is derived by Podman from the contents of the file 1224 _/etc/subuid_ and the UID of the user calling Podman. 1225 1226 First mapping step: 1227 1228 | host UID | intermediate UID | 1229 | - | - | 1230 | UID for the user starting Podman | 0 | 1231 | 1st subordinate UID for the user starting Podman | 1 | 1232 | 2nd subordinate UID for the user starting Podman | 2 | 1233 | 3rd subordinate UID for the user starting Podman | 3 | 1234 | nth subordinate UID for the user starting Podman | n | 1235 1236 To be able to use intermediate UIDs greater than zero, the user needs to have 1237 subordinate UIDs configured in _/etc/subuid_. See **subuid**(5). 1238 1239 The second mapping step is configured with **--uidmap**. 1240 1241 If for example _amount_ is **5** the second mapping step would look like: 1242 1243 | intermediate UID | container UID | 1244 | - | - | 1245 | _from_uid_ | _container_uid_ | 1246 | _from_uid_ + 1 | _container_uid_ + 1 | 1247 | _from_uid_ + 2 | _container_uid_ + 2 | 1248 | _from_uid_ + 3 | _container_uid_ + 3 | 1249 | _from_uid_ + 4 | _container_uid_ + 4 | 1250 1251 When running as rootless, Podman will use all the ranges configured in the _/etc/subuid_ file. 1252 1253 The current user ID is mapped to UID=0 in the rootless user namespace. 1254 Every additional range is added sequentially afterward: 1255 1256 | host |rootless user namespace | length | 1257 | - | - | - | 1258 | $UID | 0 | 1 | 1259 | 1 | $FIRST_RANGE_ID | $FIRST_RANGE_LENGTH | 1260 | 1+$FIRST_RANGE_LENGTH | $SECOND_RANGE_ID | $SECOND_RANGE_LENGTH| 1261 1262 Even if a user does not have any subordinate UIDs in _/etc/subuid_, 1263 **--uidmap** could still be used to map the normal UID of the user to a 1264 container UID by running `podman run --uidmap $container_uid:0:1 --user $container_uid ...`. 1265 1266 Note: the **--uidmap** flag cannot be called in conjunction with the **--pod** flag as a uidmap cannot be set on the container level when in a pod. 1267 1268 #### **--ulimit**=*option* 1269 1270 Ulimit options. You can use **host** to copy the current configuration from the host. 1271 1272 #### **--umask**=*umask* 1273 1274 Set the umask inside the container. Defaults to `0022`. 1275 Remote connections use local containers.conf for defaults 1276 1277 #### **--unsetenv**=*env* 1278 1279 Unset default environment variables for the container. Default environment 1280 variables include variables provided natively by Podman, environment variables 1281 configured by the image, and environment variables from containers.conf. 1282 1283 #### **--unsetenv-all**=*true|false* 1284 1285 Unset all default environment variables for the container. Default environment 1286 variables include variables provided natively by Podman, environment variables 1287 configured by the image, and environment variables from containers.conf. 1288 1289 #### **--user**, **-u**=[_user_ | _user_:_group_ | _uid_ | _uid_:_gid_ | _user_:_gid_ | _uid_:_group_ ] 1290 1291 Sets the username or UID used and optionally the groupname or GID for the specified command. 1292 1293 Without this argument, the command will run as the user specified in the container image. Unless overridden by a `USER` command in the Containerfile or by a value passed to this option, this user generally defaults to root. 1294 1295 When a user namespace is not in use, the UID and GID used within the container and on the host will match. When user namespaces are in use, however, the UID and GID in the container may correspond to another UID and GID on the host. In rootless containers, for example, a user namespace is always used, and root in the container will by default correspond to the UID and GID of the user invoking Podman. 1296 1297 #### **--userns**=*mode* 1298 1299 Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options. 1300 1301 Rootless user --userns=Key mappings: 1302 1303 Key | Host User | Container User 1304 ----------|---------------|--------------------- 1305 "" |$UID |0 (Default User account mapped to root user in container.) 1306 keep-id |$UID |$UID (Map user account to same UID within container.) 1307 auto |$UID | nil (Host User UID is not mapped into container.) 1308 nomap |$UID | nil (Host User UID is not mapped into container.) 1309 1310 Valid _mode_ values are: 1311 1312 **auto**[:_OPTIONS,..._]: automatically create a unique user namespace. 1313 1314 The `--userns=auto` flag, requires that the user name `containers` and a range of subordinate user ids that the Podman container is allowed to use be specified in the /etc/subuid and /etc/subgid files. 1315 1316 Example: `containers:2147483647:2147483648`. 1317 1318 Podman allocates unique ranges of UIDs and GIDs from the `containers` subordinate user ids. The size of the ranges is based on the number of UIDs required in the image. The number of UIDs and GIDs can be overridden with the `size` option. 1319 1320 The rootless option `--userns=keep-id` uses all the subuids and subgids of the user. Using `--userns=auto` when starting new containers will not work as long as any containers exist that were started with `--userns=keep-id`. 1321 1322 Valid `auto` options: 1323 1324 - *gidmapping*=_CONTAINER_GID:HOST_GID:SIZE_: to force a GID mapping to be present in the user namespace. 1325 - *size*=_SIZE_: to specify an explicit size for the automatic user namespace. e.g. `--userns=auto:size=8192`. If `size` is not specified, `auto` will estimate a size for the user namespace. 1326 - *uidmapping*=_CONTAINER_UID:HOST_UID:SIZE_: to force a UID mapping to be present in the user namespace. 1327 1328 **container:**_id_: join the user namespace of the specified container. 1329 1330 **host**: run in the user namespace of the caller. The processes running in the container will have the same privileges on the host as any other process launched by the calling user (default). 1331 1332 **keep-id**: creates a user namespace where the current rootless user's UID:GID are mapped to the same values in the container. This option is not allowed for containers created by the root user. 1333 1334 **nomap**: creates a user namespace where the current rootless user's UID:GID are not mapped into the container. This option is not allowed for containers created by the root user. 1335 1336 **ns:**_namespace_: run the container in the given existing user namespace. 1337 1338 **private**: create a new namespace for the container. 1339 This option is incompatible with **--gidmap**, **--uidmap**, **--subuidname** and **--subgidname**. 1340 1341 #### **--uts**=*mode* 1342 1343 Set the UTS namespace mode for the container. The following values are supported: 1344 1345 - **host**: use the host's UTS namespace inside the container. 1346 - **private**: create a new namespace for the container (default). 1347 - **ns:[path]**: run the container in the given existing UTS namespace. 1348 - **container:[container]**: join the UTS namespace of the specified container. 1349 1350 #### **--variant**=*VARIANT* 1351 Use _VARIANT_ instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7. 1352 1353 #### **--volume**, **-v**[=*[[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]*] 1354 1355 Create a bind mount. If you specify _/HOST-DIR_:_/CONTAINER-DIR_, Podman 1356 bind mounts _host-dir_ in the host to _CONTAINER-DIR_ in the Podman 1357 container. Similarly, _SOURCE-VOLUME_:_/CONTAINER-DIR_ will mount the volume 1358 in the host to the container. If no such named volume exists, Podman will 1359 create one. (Note when using the remote client, including Mac and Windows (excluding WSL2) machines, the volumes will be mounted from the remote server, not necessarily the client machine.) 1360 1361 The _options_ is a comma-separated list and can be: <sup>[[1]](#Footnote1)</sup> 1362 1363 * **rw**|**ro** 1364 * **z**|**Z** 1365 * [**r**]**shared**|[**r**]**slave**|[**r**]**private**[**r**]**unbindable** 1366 * [**r**]**bind** 1367 * [**no**]**exec** 1368 * [**no**]**dev** 1369 * [**no**]**suid** 1370 * [**O**] 1371 * [**U**] 1372 1373 The `CONTAINER-DIR` must be an absolute path such as `/src/docs`. The volume 1374 will be mounted into the container at this directory. 1375 1376 Volumes may specify a source as well, as either a directory on the host 1377 or the name of a named volume. If no source is given, the volume will be created as an 1378 anonymously named volume with a randomly generated name, and will be removed when 1379 the container is removed via the `--rm` flag or `podman rm --volumes`. 1380 1381 If a volume source is specified, it must be a path on the host or the name of a 1382 named volume. Host paths are allowed to be absolute or relative; relative paths 1383 are resolved relative to the directory Podman is run in. If the source does not 1384 exist, Podman will return an error. Users must pre-create the source files or 1385 directories. 1386 1387 Any source that does not begin with a `.` or `/` will be treated as the name of 1388 a named volume. If a volume with that name does not exist, it will be created. 1389 Volumes created with names are not anonymous, and they are not removed by the `--rm` 1390 option and the `podman rm --volumes` command. 1391 1392 You can specify multiple **-v** options to mount one or more volumes into a 1393 container. 1394 1395 `Write Protected Volume Mounts` 1396 1397 You can add **:ro** or **:rw** option to mount a volume in read-only or 1398 read-write mode, respectively. By default, the volumes are mounted read-write. 1399 1400 `Chowning Volume Mounts` 1401 1402 By default, Podman does not change the owner and group of source volume 1403 directories mounted into containers. If a container is created in a new user 1404 namespace, the UID and GID in the container may correspond to another UID and 1405 GID on the host. 1406 1407 The `:U` suffix tells Podman to use the correct host UID and GID based on the 1408 UID and GID within the container, to change recursively the owner and group of 1409 the source volume. 1410 1411 **Warning** use with caution since this will modify the host filesystem. 1412 1413 `Labeling Volume Mounts` 1414 1415 Labeling systems like SELinux require that proper labels are placed on volume 1416 content mounted into a container. Without a label, the security system might 1417 prevent the processes running inside the container from using the content. By 1418 default, Podman does not change the labels set by the OS. 1419 1420 To change a label in the container context, you can add either of two suffixes 1421 **:z** or **:Z** to the volume mount. These suffixes tell Podman to relabel file 1422 objects on the shared volumes. The **z** option tells Podman that two containers 1423 share the volume content. As a result, Podman labels the content with a shared 1424 content label. Shared volume labels allow all containers to read/write content. 1425 The **Z** option tells Podman to label the content with a private unshared label. 1426 1427 Note: Do not relabel system files and directories. Relabeling system content 1428 might cause other confined services on your machine to fail. For these types 1429 of containers we recommend disabling SELinux separation. The option 1430 `--security-opt label=disable` disables SELinux separation for the container. 1431 For example if a user wanted to volume mount their entire home directory into a 1432 container, they need to disable SELinux separation. 1433 1434 $ podman run --security-opt label=disable -v $HOME:/home/user fedora touch /home/user/file 1435 1436 `Overlay Volume Mounts` 1437 1438 The `:O` flag tells Podman to mount the directory from the host as a 1439 temporary storage using the `overlay file system`. The container processes 1440 can modify content within the mountpoint which is stored in the 1441 container storage in a separate directory. In overlay terms, the source 1442 directory will be the lower, and the container storage directory will be the 1443 upper. Modifications to the mount point are destroyed when the container 1444 finishes executing, similar to a tmpfs mount point being unmounted. 1445 1446 For advanced users overlay option also supports custom non-volatile `upperdir` and `workdir` 1447 for the overlay mount. Custom `upperdir` and `workdir` can be fully managed by the users themselves 1448 and `podman` will not remove it on lifecycle completion. Example `:O,upperdir=/some/upper,workdir=/some/work` 1449 1450 Subsequent executions of the container will see the original source directory 1451 content, any changes from previous container executions no longer exist. 1452 1453 One use case of the overlay mount is sharing the package cache from the 1454 host into the container to allow speeding up builds. 1455 1456 Note: 1457 1458 - The `O` flag conflicts with other options listed above. 1459 Content mounted into the container is labeled with the private label. 1460 On SELinux systems, labels in the source directory must be readable 1461 by the container label. Usually containers can read/execute `container_share_t` 1462 and can read/write `container_file_t`. If you cannot change the labels on a 1463 source volume, SELinux container separation must be disabled for the container 1464 to work. 1465 - The source directory mounted into the container with an overlay mount 1466 should not be modified, it can cause unexpected failures. It is recommended 1467 that you do not modify the directory until the container finishes running. 1468 1469 Only the current container can use a private volume. 1470 1471 `Mounts propagation` 1472 1473 By default bind mounted volumes are `private`. That means any mounts done 1474 inside container will not be visible on host and vice versa. One can change 1475 this behavior by specifying a volume mount propagation property. Making a 1476 volume shared mounts done under that volume inside container will be 1477 visible on host and vice versa. Making a volume **slave** enables only one 1478 way mount propagation and that is mounts done on host under that volume 1479 will be visible inside container but not the other way around. <sup>[[1]](#Footnote1)</sup> 1480 1481 To control mount propagation property of volume one can use [**r**]**shared**, 1482 [**r**]**slave**, [**r**]**private** or [**r**]**unbindable** propagation flag. 1483 Propagation property can be specified only for bind mounted volumes and not for 1484 internal volumes or named volumes. For mount propagation to work source mount 1485 point (mount point where source dir is mounted on) has to have right propagation 1486 properties. For shared volumes, source mount point has to be shared. And for 1487 slave volumes, source mount has to be either shared or slave. 1488 <sup>[[1]](#Footnote1)</sup> 1489 1490 If you want to recursively mount a volume and all of its submounts into a 1491 container, then you can use the **rbind** option. By default the bind option is 1492 used, and submounts of the source directory will not be mounted into the 1493 container. 1494 1495 Mounting the volume with the **nosuid** options means that SUID applications on 1496 the volume will not be able to change their privilege. By default volumes 1497 are mounted with **nosuid**. 1498 1499 Mounting the volume with the **noexec** option means that no executables on the 1500 volume will be able to be executed within the container. 1501 1502 Mounting the volume with the **nodev** option means that no devices on the volume 1503 will be able to be used by processes within the container. By default volumes 1504 are mounted with **nodev**. 1505 1506 If the _host-dir_ is a mount point, then **dev**, **suid**, and **exec** options are 1507 ignored by the kernel. 1508 1509 Use **df $hostdir** to figure out the source mount, and then use 1510 **findmnt -o TARGET,PROPAGATION _source-mount-dir_** to figure out propagation 1511 properties of source mount. If **findmnt**(1) utility is not available, then one 1512 can look at mount entry for source mount point in _/proc/self/mountinfo_. Look 1513 at the "optional fields" and see if any propagation properties are specified. 1514 In there, **shared:N** means the mount is shared, **master:N** means mount 1515 is slave, and if nothing is there, the mount is private. <sup>[[1]](#Footnote1)</sup> 1516 1517 To change propagation properties of a mount point, use **mount**(8) command. For 1518 example, if one wants to bind mount source directory _/foo_, one can do 1519 **mount --bind /foo /foo** and **mount --make-private --make-shared /foo**. This 1520 will convert /foo into a shared mount point. Alternatively, one can directly 1521 change propagation properties of source mount. Say, if _/_ is source mount for 1522 _/foo_, then use **mount --make-shared /** to convert _/_ into a shared mount. 1523 1524 Note: if the user only has access rights via a group, accessing the volume 1525 from inside a rootless container will fail. Use the `--group-add keep-groups` 1526 flag to pass the user's supplementary group access into the container. 1527 1528 #### **--volumes-from**[=*CONTAINER*[:*OPTIONS*]] 1529 1530 Mount volumes from the specified container(s). Used to share volumes between 1531 containers. The *options* is a comma-separated list with the following available elements: 1532 1533 * **rw**|**ro** 1534 * **z** 1535 1536 Mounts already mounted volumes from a source container onto another 1537 container. You must supply the source's container-id or container-name. 1538 To share a volume, use the --volumes-from option when running 1539 the target container. You can share volumes even if the source container 1540 is not running. 1541 1542 By default, Podman mounts the volumes in the same mode (read-write or 1543 read-only) as it is mounted in the source container. 1544 You can change this by adding a `ro` or `rw` _option_. 1545 1546 Labeling systems like SELinux require that proper labels are placed on volume 1547 content mounted into a container. Without a label, the security system might 1548 prevent the processes running inside the container from using the content. By 1549 default, Podman does not change the labels set by the OS. 1550 1551 To change a label in the container context, you can add `z` to the volume mount. 1552 This suffix tells Podman to relabel file objects on the shared volumes. The `z` 1553 option tells Podman that two containers share the volume content. As a result, 1554 Podman labels the content with a shared content label. Shared volume labels allow 1555 all containers to read/write content. 1556 1557 If the location of the volume from the source container overlaps with 1558 data residing on a target container, then the volume hides 1559 that data on the target. 1560 1561 #### **--workdir**, **-w**=*dir* 1562 1563 Working directory inside the container. 1564 1565 The default working directory for running binaries within a container is the root directory (**/**). 1566 The image developer can set a different default with the WORKDIR instruction. The operator 1567 can override the working directory by using the **-w** option. 1568 1569 ## Exit Status 1570 1571 The exit code from **podman run** gives information about why the container 1572 failed to run or why it exited. When **podman run** exits with a non-zero code, 1573 the exit codes follow the **chroot**(1) standard, see below: 1574 1575 **125** The error is with Podman itself 1576 1577 $ podman run --foo busybox; echo $? 1578 Error: unknown flag: --foo 1579 125 1580 1581 **126** The _contained command_ cannot be invoked 1582 1583 $ podman run busybox /etc; echo $? 1584 Error: container_linux.go:346: starting container process caused "exec: \"/etc\": permission denied": OCI runtime error 1585 126 1586 1587 **127** The _contained command_ cannot be found 1588 1589 $ podman run busybox foo; echo $? 1590 Error: container_linux.go:346: starting container process caused "exec: \"foo\": executable file not found in $PATH": OCI runtime error 1591 127 1592 1593 **Exit code** _contained command_ exit code 1594 1595 $ podman run busybox /bin/sh -c 'exit 3'; echo $? 1596 3 1597 1598 ## EXAMPLES 1599 1600 ### Running container in read-only mode 1601 1602 During container image development, containers often need to write to the image 1603 content. Installing packages into _/usr_, for example. In production, 1604 applications seldom need to write to the image. Container applications write 1605 to volumes if they need to write to file systems at all. Applications can be 1606 made more secure by running them in read-only mode using the **--read-only** switch. 1607 This protects the containers image from modification. Read only containers may 1608 still need to write temporary data. The best way to handle this is to mount 1609 tmpfs directories on _/run_ and _/tmp_. 1610 1611 ``` 1612 $ podman run --read-only -i -t fedora /bin/bash 1613 1614 $ podman run --read-only --read-only-tmpfs=false --tmpfs /run -i -t fedora /bin/bash 1615 ``` 1616 1617 ### Exposing log messages from the container to the host's log 1618 1619 If you want messages that are logged in your container to show up in the host's 1620 syslog/journal then you should bind mount the _/dev/log_ directory as follows. 1621 1622 ``` 1623 $ podman run -v /dev/log:/dev/log -i -t fedora /bin/bash 1624 ``` 1625 1626 From inside the container you can test this by sending a message to the log. 1627 1628 ``` 1629 (bash)# logger "Hello from my container" 1630 ``` 1631 1632 Then exit and check the journal. 1633 1634 ``` 1635 (bash)# exit 1636 1637 $ journalctl -b | grep Hello 1638 ``` 1639 1640 This should list the message sent to logger. 1641 1642 ### Attaching to one or more from STDIN, STDOUT, STDERR 1643 1644 If you do not specify **-a**, Podman will attach everything (stdin, stdout, stderr). 1645 You can specify to which of the three standard streams (stdin, stdout, stderr) 1646 you'd like to connect instead, as in: 1647 1648 ``` 1649 $ podman run -a stdin -a stdout -i -t fedora /bin/bash 1650 ``` 1651 1652 ### Sharing IPC between containers 1653 1654 Using **shm_server.c** available here: https://www.cs.cf.ac.uk/Dave/C/node27.html 1655 1656 Testing **--ipc=host** mode: 1657 1658 Host shows a shared memory segment with 7 pids attached, happens to be from httpd: 1659 1660 ``` 1661 $ sudo ipcs -m 1662 1663 ------ Shared Memory Segments -------- 1664 key shmid owner perms bytes nattch status 1665 0x01128e25 0 root 600 1000 7 1666 ``` 1667 1668 Now run a regular container, and it correctly does NOT see the shared memory segment from the host: 1669 1670 ``` 1671 $ podman run -it shm ipcs -m 1672 1673 ------ Shared Memory Segments -------- 1674 key shmid owner perms bytes nattch status 1675 ``` 1676 1677 Run a container with the new **--ipc=host** option, and it now sees the shared memory segment from the host httpd: 1678 1679 ``` 1680 $ podman run -it --ipc=host shm ipcs -m 1681 1682 ------ Shared Memory Segments -------- 1683 key shmid owner perms bytes nattch status 1684 0x01128e25 0 root 600 1000 7 1685 ``` 1686 Testing **--ipc=container:**_id_ mode: 1687 1688 Start a container with a program to create a shared memory segment: 1689 ``` 1690 $ podman run -it shm bash 1691 $ sudo shm/shm_server & 1692 $ sudo ipcs -m 1693 1694 ------ Shared Memory Segments -------- 1695 key shmid owner perms bytes nattch status 1696 0x0000162e 0 root 666 27 1 1697 ``` 1698 Create a 2nd container correctly shows no shared memory segment from 1st container: 1699 ``` 1700 $ podman run shm ipcs -m 1701 1702 ------ Shared Memory Segments -------- 1703 key shmid owner perms bytes nattch status 1704 ``` 1705 1706 Create a 3rd container using the **--ipc=container:**_id_ option, now it shows the shared memory segment from the first: 1707 1708 ``` 1709 $ podman run -it --ipc=container:ed735b2264ac shm ipcs -m 1710 $ sudo ipcs -m 1711 1712 ------ Shared Memory Segments -------- 1713 key shmid owner perms bytes nattch status 1714 0x0000162e 0 root 666 27 1 1715 ``` 1716 1717 ### Mapping Ports for External Usage 1718 1719 The exposed port of an application can be mapped to a host port using the **-p** 1720 flag. For example, an httpd port 80 can be mapped to the host port 8080 using the 1721 following: 1722 1723 ``` 1724 $ podman run -p 8080:80 -d -i -t fedora/httpd 1725 ``` 1726 1727 ### Mounting External Volumes 1728 1729 To mount a host directory as a container volume, specify the absolute path to 1730 the directory and the absolute path for the container directory separated by a 1731 colon. If the source is a named volume maintained by Podman, it is recommended to 1732 use its name rather than the path to the volume. Otherwise the volume will be 1733 considered as an orphan and wiped if you execute **podman volume prune**: 1734 1735 ``` 1736 $ podman run -v /var/db:/data1 -i -t fedora bash 1737 1738 $ podman run -v data:/data2 -i -t fedora bash 1739 1740 $ podman run -v /var/cache/dnf:/var/cache/dnf:O -ti fedora dnf -y update 1741 1742 $ podman run -d -e MYSQL_ROOT_PASSWORD=root --user mysql --userns=keep-id -v ~/data:/var/lib/mysql:z,U mariadb 1743 ``` 1744 1745 Using **--mount** flags to mount a host directory as a container folder, specify 1746 the absolute path to the directory or the volume name, and the absolute path 1747 within the container directory: 1748 1749 ```` 1750 $ podman run --mount type=bind,src=/var/db,target=/data1 busybox sh 1751 1752 $ podman run --mount type=bind,src=volume-name,target=/data1 busybox sh 1753 ```` 1754 1755 When using SELinux, be aware that the host has no knowledge of container SELinux 1756 policy. Therefore, in the above example, if SELinux policy is enforced, the 1757 _/var/db_ directory is not writable to the container. A "Permission Denied" 1758 message will occur and an **avc:** message in the host's syslog. 1759 1760 To work around this, at time of writing this man page, the following command 1761 needs to be run in order for the proper SELinux policy type label to be attached 1762 to the host directory: 1763 1764 ``` 1765 $ chcon -Rt svirt_sandbox_file_t /var/db 1766 ``` 1767 1768 Now, writing to the _/data1_ volume in the container will be allowed and the 1769 changes will also be reflected on the host in _/var/db_. 1770 1771 ### Using alternative security labeling 1772 1773 You can override the default labeling scheme for each container by specifying 1774 the **--security-opt** flag. For example, you can specify the MCS/MLS level, a 1775 requirement for MLS systems. Specifying the level in the following command 1776 allows you to share the same content between containers. 1777 1778 ``` 1779 podman run --security-opt label=level:s0:c100,c200 -i -t fedora bash 1780 ``` 1781 1782 An MLS example might be: 1783 1784 ``` 1785 $ podman run --security-opt label=level:TopSecret -i -t rhel7 bash 1786 ``` 1787 1788 To disable the security labeling for this container versus running with the 1789 #### **--permissive** flag, use the following command: 1790 1791 ``` 1792 $ podman run --security-opt label=disable -i -t fedora bash 1793 ``` 1794 1795 If you want a tighter security policy on the processes within a container, 1796 you can specify an alternate type for the container. You could run a container 1797 that is only allowed to listen on Apache ports by executing the following 1798 command: 1799 1800 ``` 1801 $ podman run --security-opt label=type:svirt_apache_t -i -t centos bash 1802 ``` 1803 1804 Note you would have to write policy defining a **svirt_apache_t** type. 1805 1806 To mask additional specific paths in the container, specify the paths 1807 separated by a colon using the **mask** option with the **--security-opt** 1808 flag. 1809 1810 ``` 1811 $ podman run --security-opt mask=/foo/bar:/second/path fedora bash 1812 ``` 1813 1814 To unmask all the paths that are masked by default, set the **unmask** option to 1815 **ALL**. Or to only unmask specific paths, specify the paths as shown above with 1816 the **mask** option. 1817 1818 ``` 1819 $ podman run --security-opt unmask=ALL fedora bash 1820 ``` 1821 1822 To unmask all the paths that start with /proc, set the **unmask** option to 1823 **/proc/***. 1824 1825 ``` 1826 $ podman run --security-opt unmask=/proc/* fedora bash 1827 ``` 1828 1829 ``` 1830 $ podman run --security-opt unmask=/foo/bar:/sys/firmware fedora bash 1831 ``` 1832 1833 ### Setting device weight 1834 1835 If you want to set _/dev/sda_ device weight to **200**, you can specify the device 1836 weight by **--blkio-weight-device** flag. Use the following command: 1837 1838 ``` 1839 $ podman run -it --blkio-weight-device "/dev/sda:200" ubuntu 1840 ``` 1841 1842 ### Using a podman container with input from a pipe 1843 1844 ``` 1845 $ echo "asdf" | podman run --rm -i --entrypoint /bin/cat someimage 1846 asdf 1847 ``` 1848 1849 ### Setting automatic user namespace separated containers 1850 1851 ``` 1852 # podman run --userns=auto:size=65536 ubi8-micro cat /proc/self/uid_map 1853 0 2147483647 65536 1854 # podman run --userns=auto:size=65536 ubi8-micro cat /proc/self/uid_map 1855 0 2147549183 65536 1856 ``` 1857 1858 ### Setting Namespaced Kernel Parameters (Sysctls) 1859 1860 The **--sysctl** sets namespaced kernel parameters (sysctls) in the 1861 container. For example, to turn on IP forwarding in the containers 1862 network namespace, run this command: 1863 1864 ``` 1865 $ podman run --sysctl net.ipv4.ip_forward=1 someimage 1866 ``` 1867 1868 Note that not all sysctls are namespaced. Podman does not support changing sysctls 1869 inside of a container that also modify the host system. As the kernel 1870 evolves we expect to see more sysctls become namespaced. 1871 1872 See the definition of the **--sysctl** option above for the current list of 1873 supported sysctls. 1874 1875 ### Set UID/GID mapping in a new user namespace 1876 1877 Running a container in a new user namespace requires a mapping of 1878 the uids and gids from the host. 1879 1880 ``` 1881 $ podman run --uidmap 0:30000:7000 --gidmap 0:30000:7000 fedora echo hello 1882 ``` 1883 1884 ### Configuring Storage Options from the command line 1885 1886 Podman allows for the configuration of storage by changing the values 1887 in the _/etc/container/storage.conf_ or by using global options. This 1888 shows how to setup and use fuse-overlayfs for a one time run of busybox 1889 using global options. 1890 1891 ``` 1892 podman --log-level=debug --storage-driver overlay --storage-opt "overlay.mount_program=/usr/bin/fuse-overlayfs" run busybox /bin/sh 1893 ``` 1894 1895 ### Configure timezone in a container 1896 1897 ``` 1898 $ podman run --tz=local alpine date 1899 $ podman run --tz=Asia/Shanghai alpine date 1900 $ podman run --tz=US/Eastern alpine date 1901 ``` 1902 1903 ### Adding dependency containers 1904 1905 The first container, container1, is not started initially, but must be running before container2 will start. 1906 The `podman run` command will start the container automatically before starting container2. 1907 1908 ``` 1909 $ podman create --name container1 -t -i fedora bash 1910 $ podman run --name container2 --requires container1 -t -i fedora bash 1911 ``` 1912 1913 Multiple containers can be required. 1914 1915 ``` 1916 $ podman create --name container1 -t -i fedora bash 1917 $ podman create --name container2 -t -i fedora bash 1918 $ podman run --name container3 --requires container1,container2 -t -i fedora bash 1919 ``` 1920 1921 ### Configure keep supplemental groups for access to volume 1922 1923 ``` 1924 $ podman run -v /var/lib/design:/var/lib/design --group-add keep-groups ubi8 1925 ``` 1926 1927 ### Configure execution domain for containers using personality flag 1928 1929 ``` 1930 $ podman run --name container1 --personaity=LINUX32 fedora bash 1931 ``` 1932 1933 ### Run a container with external rootfs mounted as an overlay 1934 1935 ``` 1936 $ podman run --name container1 --rootfs /path/to/rootfs:O bash 1937 ``` 1938 1939 ### Handling Timezones in java applications in a container. 1940 1941 In order to use a timezone other than UTC when running a 1942 Java application within a container, the `TZ` environment variable must be 1943 set within the container. Java applications will ignore the value set with the 1944 `--tz` option. 1945 1946 ``` 1947 # Example run 1948 podman run -ti --rm -e TZ=EST mytzimage 1949 lrwxrwxrwx. 1 root root 29 Nov 3 08:51 /etc/localtime -> ../usr/share/zoneinfo/Etc/UTC 1950 Now with default timezone: 1951 Fri Nov 19 18:10:55 EST 2021 1952 Java default sees the following timezone: 1953 2021-11-19T18:10:55.651130-05:00 1954 Forcing UTC: 1955 Fri Nov 19 23:10:55 UTC 2021 1956 ``` 1957 1958 ### Run a container connected to two networks (called net1 and net2) with a static ip 1959 1960 ``` 1961 $ podman run --network net1:ip=10.89.1.5 --network net2:ip=10.89.10.10 alpine ip addr 1962 ``` 1963 1964 ### Rootless Containers 1965 1966 Podman runs as a non-root user on most systems. This feature requires that a new enough version of **shadow-utils** 1967 be installed. The **shadow-utils** package must include the **newuidmap**(1) and **newgidmap**(1) executables. 1968 1969 In order for users to run rootless, there must be an entry for their username in _/etc/subuid_ and _/etc/subgid_ which lists the UIDs for their user namespace. 1970 1971 Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed. 1972 The **fuse-overlayfs** package provides a userspace overlay storage driver, otherwise users need to use 1973 the **vfs** storage driver, which is diskspace expensive and does not perform well. slirp4netns is 1974 required for VPN, without it containers need to be run with the **--network=host** flag. 1975 1976 ## ENVIRONMENT 1977 1978 Environment variables within containers can be set using multiple different options, 1979 in the following order of precedence (later entries override earlier entries): 1980 1981 - Container image: Any environment variables specified in the container image. 1982 - **--http-proxy**: By default, several environment variables will be passed in from the host, such as **http_proxy** and **no_proxy**. See **--http-proxy** for details. 1983 - **--env-host**: Host environment of the process executing Podman is added. 1984 - **--env-file**: Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry. 1985 - **--env**: Any environment variables specified will override previous settings. 1986 1987 Run containers and set the environment ending with a __*__ and a __*****__: 1988 1989 ``` 1990 $ export ENV1=a 1991 $ podman run --env ENV* alpine printenv ENV1 1992 a 1993 1994 $ podman run --env ENV*****=b alpine printenv ENV***** 1995 b 1996 ``` 1997 1998 ## CONMON 1999 2000 When Podman starts a container it actually executes the conmon program, which 2001 then executes the OCI Runtime. Conmon is the container monitor. It is a small 2002 program whose job is to watch the primary process of the container, and if the 2003 container dies, save the exit code. It also holds open the tty of the 2004 container, so that it can be attached to later. This is what allows Podman to 2005 run in detached mode (backgrounded), so Podman can exit but conmon continues to 2006 run. Each container has their own instance of conmon. Conmon waits for the 2007 container to exit, gathers and saves the exit code, and then launches a Podman 2008 process to complete the container cleanup, by shutting down the network and 2009 storage. For more information on conmon, please reference the conmon(8) man 2010 page. 2011 2012 ## FILES 2013 2014 **/etc/subuid** 2015 2016 **/etc/subgid** 2017 2018 NOTE: Use the environment variable `TMPDIR` to change the temporary storage location of downloaded container images. Podman defaults to use `/var/tmp`. 2019 2020 ## SEE ALSO 2021 **[podman(1)](podman.1.md)**, **[podman-save(1)](podman-save.1.md)**, **[podman-ps(1)](podman-ps.1.md)**, **[podman-attach(1)](podman-attach.1.md)**, **[podman-pod-create(1)](podman-pod-create.1.md)**, **[podman-port(1)](podman-port.1.md)**, **[podman-start(1)](podman-start.1.md)**, **[podman-kill(1)](podman-kill.1.md)**, **[podman-stop(1)](podman-stop.1.md)**, **[podman-generate-systemd(1)](podman-generate-systemd.1.md)**, **[podman-rm(1)](podman-rm.1.md)**, **[subgid(5)](https://www.unix.com/man-page/linux/5/subgid)**, **[subuid(5)](https://www.unix.com/man-page/linux/5/subuid)**, **[containers.conf(5)](https://github.com/containers/common/blob/main/docs/containers.conf.5.md)**, **[systemd.unit(5)](https://www.freedesktop.org/software/systemd/man/systemd.unit.html)**, **[setsebool(8)](https://man7.org/linux/man-pages/man8/setsebool.8.html)**, **[slirp4netns(1)](https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md)**, **[fuse-overlayfs(1)](https://github.com/containers/fuse-overlayfs/blob/main/fuse-overlayfs.1.md)**, **proc(5)**, **[conmon(8)](https://github.com/containers/conmon/blob/main/docs/conmon.8.md)**, **personality(2)** 2022 2023 ## HISTORY 2024 September 2018, updated by Kunal Kushwaha `<kushwaha_kunal_v7@lab.ntt.co.jp>` 2025 2026 October 2017, converted from Docker documentation to Podman by Dan Walsh for Podman `<dwalsh@redhat.com>` 2027 2028 November 2015, updated by Sally O'Malley `<somalley@redhat.com>` 2029 2030 June 2014, updated by Sven Dowideit `<SvenDowideit@home.org.au>` 2031 2032 April 2014, Originally compiled by William Henry `<whenry@redhat.com>` based on docker.com source material and internal work. 2033 2034 ## FOOTNOTES 2035 <a name="Footnote1">1</a>: The Podman project is committed to inclusivity, a core value of open source. The `master` and `slave` mount propagation terminology used here is problematic and divisive, and should be changed. However, these terms are currently used within the Linux kernel and must be used as-is at this time. When the kernel maintainers rectify this usage, Podman will follow suit immediately.