github.com/containers/podman/v5@v5.1.0-rc1/docs/source/markdown/podman-create.1.md.in (about)

     1  % podman-create 1
     2  
     3  ## NAME
     4  podman\-create - Create a new container
     5  
     6  ## SYNOPSIS
     7  **podman create** [*options*] *image* [*command* [*arg* ...]]
     8  
     9  **podman container create** [*options*] *image* [*command* [*arg* ...]]
    10  
    11  ## DESCRIPTION
    12  
    13  Creates a writable container layer over the specified image and prepares it for
    14  running the specified command. The container ID is then printed to STDOUT. This
    15  is similar to **podman run -d** except the container is never started. Use the
    16  **podman start** *container* command to start the container at any point.
    17  
    18  The initial status of the container created with **podman create** is 'created'.
    19  
    20  Default settings for flags are defined in `containers.conf`. Most settings for
    21  remote connections use the server's containers.conf, except when documented in
    22  man pages.
    23  
    24  ## IMAGE
    25  
    26    The image is specified using transport:path format. If no transport is specified, the `docker` (container registry)
    27  transport is used by default. For remote Podman, including Mac and Windows (excluding WSL2) machines, `docker` is the only allowed transport.
    28  
    29    **dir:**_path_
    30    An existing local directory _path_ storing the manifest, layer tarballs and signatures as individual files. This
    31  is a non-standardized format, primarily useful for debugging or noninvasive container inspection.
    32  
    33      $ podman save --format docker-dir fedora -o /tmp/fedora
    34      $ podman create dir:/tmp/fedora echo hello
    35  
    36    **docker://**_docker-reference_ (Default)
    37    An image reference stored in  a remote container image registry. Example: "quay.io/podman/stable:latest".
    38  The reference can include a path to a specific registry; if it does not, the
    39  registries listed in registries.conf is queried to find a matching image.
    40  By default, credentials from `podman login` (stored at
    41  $XDG_RUNTIME_DIR/containers/auth.json by default) is used to authenticate;
    42  otherwise it falls back to using credentials in $HOME/.docker/config.json.
    43  
    44      $ podman create registry.fedoraproject.org/fedora:latest echo hello
    45  
    46    **docker-archive:**_path_[**:**_docker-reference_]
    47  An image stored in the `docker save` formatted file. _docker-reference_ is only used when creating such a
    48  file, and it must not contain a digest.
    49  
    50      $ podman save --format docker-archive fedora -o /tmp/fedora
    51      $ podman create docker-archive:/tmp/fedora echo hello
    52  
    53    **docker-daemon:**_docker-reference_
    54    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).
    55  
    56      $ sudo docker pull fedora
    57      $ sudo podman create docker-daemon:docker.io/library/fedora echo hello
    58  
    59    **oci-archive:**_path_**:**_tag_
    60    An image in a directory compliant with the "Open Container Image Layout Specification" at the specified _path_
    61  and specified with a _tag_.
    62  
    63      $ podman save --format oci-archive fedora -o /tmp/fedora
    64      $ podman create oci-archive:/tmp/fedora echo hello
    65  
    66  ## OPTIONS
    67  
    68  @@option add-host
    69  
    70  @@option annotation.container
    71  
    72  @@option arch
    73  
    74  @@option attach
    75  
    76  @@option authfile
    77  
    78  @@option blkio-weight
    79  
    80  @@option blkio-weight-device
    81  
    82  @@option cap-add
    83  
    84  @@option cap-drop
    85  
    86  @@option cgroup-conf
    87  
    88  @@option cgroup-parent
    89  
    90  @@option cgroupns
    91  
    92  @@option cgroups
    93  
    94  @@option chrootdirs
    95  
    96  @@option cidfile.write
    97  
    98  @@option conmon-pidfile
    99  
   100  @@option cpu-period
   101  
   102  @@option cpu-quota
   103  
   104  @@option cpu-rt-period
   105  
   106  @@option cpu-rt-runtime
   107  
   108  @@option cpu-shares
   109  
   110  @@option cpus.container
   111  
   112  @@option cpuset-cpus
   113  
   114  @@option cpuset-mems
   115  
   116  @@option decryption-key
   117  
   118  @@option device
   119  
   120  Note: if the user only has access rights via a group, accessing the device
   121  from inside a rootless container fails. Use the `--group-add keep-groups`
   122  flag to pass the user's supplementary group access into the container.
   123  
   124  @@option device-cgroup-rule
   125  
   126  @@option device-read-bps
   127  
   128  @@option device-read-iops
   129  
   130  @@option device-write-bps
   131  
   132  @@option device-write-iops
   133  
   134  @@option disable-content-trust
   135  
   136  @@option dns
   137  
   138  This option cannot be combined with **--network** that is set to **none** or **container:**_id_.
   139  
   140  @@option dns-option.container
   141  
   142  @@option dns-search.container
   143  
   144  @@option entrypoint
   145  
   146  @@option env
   147  
   148  See [**Environment**](#environment) note below for precedence and examples.
   149  
   150  @@option env-file
   151  
   152  See [**Environment**](#environment) note below for precedence and examples.
   153  
   154  @@option env-host
   155  
   156  @@option env-merge
   157  
   158  @@option expose
   159  
   160  @@option gidmap.container
   161  
   162  @@option gpus
   163  
   164  @@option group-add
   165  
   166  @@option group-entry
   167  
   168  @@option health-cmd
   169  
   170  @@option health-interval
   171  
   172  @@option health-on-failure
   173  
   174  @@option health-retries
   175  
   176  @@option health-start-period
   177  
   178  @@option health-startup-cmd
   179  
   180  @@option health-startup-interval
   181  
   182  @@option health-startup-retries
   183  
   184  @@option health-startup-success
   185  
   186  @@option health-startup-timeout
   187  
   188  @@option health-timeout
   189  
   190  #### **--help**
   191  
   192  Print usage statement
   193  
   194  @@option hostname.container
   195  
   196  @@option hostuser
   197  
   198  @@option http-proxy
   199  
   200  @@option image-volume
   201  
   202  @@option init
   203  
   204  #### **--init-ctr**=*type*
   205  
   206  (Pods only).
   207  When using pods, create an init style container, which is run after the infra container is started
   208  but before regular pod containers are started.  Init containers are useful for running
   209  setup operations for the pod's applications.
   210  
   211  Valid values for `init-ctr` type are *always* or *once*.  The *always* value
   212  means the container runs with each and every `pod start`, whereas the *once*
   213  value means the container only runs once when the pod is started and then the container is removed.
   214  
   215  Init containers are only run on pod `start`.  Restarting a pod does not execute
   216  any init containers.  Furthermore, init containers can only be created in a
   217  pod when that pod is not running.
   218  
   219  @@option init-path
   220  
   221  @@option interactive
   222  
   223  @@option ip
   224  
   225  @@option ip6
   226  
   227  @@option ipc
   228  
   229  @@option label
   230  
   231  @@option label-file
   232  
   233  @@option link-local-ip
   234  
   235  @@option log-driver
   236  
   237  @@option log-opt
   238  
   239  @@option mac-address
   240  
   241  @@option memory
   242  
   243  @@option memory-reservation
   244  
   245  @@option memory-swap
   246  
   247  @@option memory-swappiness
   248  
   249  @@option mount
   250  
   251  @@option name.container
   252  
   253  @@option network
   254  
   255  Invalid if using **--dns**, **--dns-option**, or **--dns-search** with **--network** set to **none** or **container:**_id_.
   256  
   257  If used together with **--pod**, the container does not join the pod's network namespace.
   258  
   259  @@option network-alias
   260  
   261  @@option no-healthcheck
   262  
   263  @@option no-hosts
   264  
   265  This option conflicts with **--add-host**.
   266  
   267  @@option oom-kill-disable
   268  
   269  @@option oom-score-adj
   270  
   271  @@option os.pull
   272  
   273  @@option passwd-entry
   274  
   275  @@option personality
   276  
   277  @@option pid.container
   278  
   279  @@option pidfile
   280  
   281  @@option pids-limit
   282  
   283  @@option platform
   284  
   285  @@option pod.run
   286  
   287  @@option pod-id-file.container
   288  
   289  @@option privileged
   290  
   291  @@option publish
   292  
   293  **Note:** If a container runs within a pod, it is not necessary to publish the port for
   294  the containers in the pod. The port must only be published by the pod itself. Pod network
   295  stacks act like the network stack on the host - when there are a variety of containers in the pod,
   296  and programs in the container, all sharing a single interface and IP address, and
   297  associated ports. If one container binds to a port, no other container can use that port
   298  within the pod while it is in use. Containers in the pod can also communicate over localhost
   299  by having one container bind to localhost in the pod, and another connect to that port.
   300  
   301  @@option publish-all
   302  
   303  @@option pull
   304  
   305  #### **--quiet**, **-q**
   306  
   307  Suppress output information when pulling images
   308  
   309  @@option rdt-class
   310  
   311  @@option read-only
   312  
   313  @@option read-only-tmpfs
   314  
   315  @@option replace
   316  
   317  @@option requires
   318  
   319  @@option restart
   320  
   321  @@option retry
   322  
   323  @@option retry-delay
   324  
   325  #### **--rm**
   326  
   327  Automatically remove the container and any anonymous unnamed volume associated with
   328  the container when it exits. The default is **false**.
   329  
   330  @@option rootfs
   331  
   332  @@option sdnotify
   333  
   334  @@option seccomp-policy
   335  
   336  @@option secret
   337  
   338  @@option security-opt
   339  
   340  @@option shm-size
   341  
   342  @@option shm-size-systemd
   343  
   344  @@option stop-signal
   345  
   346  @@option stop-timeout
   347  
   348  @@option subgidname
   349  
   350  @@option subuidname
   351  
   352  @@option sysctl
   353  
   354  @@option systemd
   355  
   356  @@option timeout
   357  
   358  @@option tls-verify
   359  
   360  @@option tmpfs
   361  
   362  @@option tty
   363  
   364  @@option tz
   365  
   366  @@option uidmap.container
   367  
   368  @@option ulimit
   369  
   370  @@option umask
   371  
   372  @@option unsetenv
   373  
   374  @@option unsetenv-all
   375  
   376  @@option user
   377  
   378  @@option userns.container
   379  
   380  @@option uts.container
   381  
   382  @@option variant.container
   383  
   384  @@option volume
   385  
   386  Use the **--group-add keep-groups** option to pass the user's supplementary group access into the container.
   387  
   388  @@option volumes-from
   389  
   390  @@option workdir
   391  
   392  ## EXAMPLES
   393  
   394  Create a container using a local image:
   395  ```
   396  $ podman create alpine ls
   397  ```
   398  
   399  Create a container using a local image and annotate it:
   400  ```
   401  $ podman create --annotation HELLO=WORLD alpine ls
   402  ```
   403  
   404  Create a container using a local image, allocating a pseudo-TTY, keeping stdin open and name it myctr:
   405  ```
   406    podman create -t -i --name myctr alpine ls
   407  ```
   408  
   409  Running a container in a new user namespace requires a mapping of
   410  the UIDs and GIDs from the host:
   411  ```
   412  $ podman create --uidmap 0:30000:7000 --gidmap 0:30000:7000 fedora echo hello
   413  ```
   414  
   415  Setting automatic user-namespace separated containers:
   416  ```
   417  # podman create --userns=auto:size=65536 ubi8-init
   418  ```
   419  
   420  Configure the timezone in a container:
   421  ```
   422  $ podman create --tz=local alpine date
   423  $ podman create --tz=Asia/Shanghai alpine date
   424  $ podman create --tz=US/Eastern alpine date
   425  ```
   426  
   427  Ensure the first container (container1) is running before the second container (container2) is started:
   428  ```
   429  $ podman create --name container1 -t -i fedora bash
   430  $ podman create --name container2 --requires container1 -t -i fedora bash
   431  $ podman start --attach container2
   432  ```
   433  
   434  Create a container which requires multiple containers:
   435  ```
   436  $ podman create --name container1 -t -i fedora bash
   437  $ podman create --name container2 -t -i fedora bash
   438  $ podman create --name container3 --requires container1,container2 -t -i fedora bash
   439  $ podman start --attach container3
   440  ```
   441  
   442  Expose shared libraries inside of container as read-only using a glob:
   443  ```
   444  $ podman create --mount type=glob,src=/usr/lib64/libnvidia\*,ro -i -t fedora /bin/bash
   445  ```
   446  
   447  Create a container allowing supplemental groups to have access to the volume:
   448  ```
   449  $ podman create -v /var/lib/design:/var/lib/design --group-add keep-groups ubi8
   450  ```
   451  
   452  Configure execution domain for containers using the personality option:
   453  ```
   454  $ podman create --name container1 --personality=LINUX32 fedora bash
   455  ```
   456  
   457  Create a container with external rootfs mounted as an overlay:
   458  ```
   459  $ podman create --name container1 --rootfs /path/to/rootfs:O bash
   460  ```
   461  
   462  Create a container connected to two networks (called net1 and net2) with a static ip:
   463  ```
   464  $ podman create --network net1:ip=10.89.1.5 --network net2:ip=10.89.10.10 alpine ip addr
   465  ```
   466  
   467  ### Rootless Containers
   468  
   469  Podman runs as a non-root user on most systems. This feature requires that a new enough version of shadow-utils
   470  be installed. The shadow-utils package must include the newuidmap and newgidmap executables.
   471  
   472  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.
   473  
   474  Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed.
   475  The fuse-overlayfs package provides a userspace overlay storage driver, otherwise users need to use
   476  the vfs storage driver, which can be disk space expensive and less performant
   477  than other drivers.
   478  
   479  To enable VPN on the container, slirp4netns or pasta needs to be specified;
   480  without either, containers need to be run with the --network=host flag.
   481  
   482  ## ENVIRONMENT
   483  
   484  Environment variables within containers can be set using multiple different options:  This section describes the precedence.
   485  
   486  Precedence order (later entries override earlier entries):
   487  
   488  - **--env-host** : Host environment of the process executing Podman is added.
   489  - **--http-proxy**: By default, several environment variables are passed in from the host, such as **http_proxy** and **no_proxy**. See **--http-proxy** for details.
   490  - Container image : Any environment variables specified in the container image.
   491  - **--env-file** : Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry.
   492  - **--env** : Any environment variables specified overrides previous settings.
   493  
   494  Create containers and set the environment ending with a __*__.
   495  The trailing __*__ glob functionality is only active when no value is specified:
   496  
   497  ```
   498  $ export ENV1=a
   499  $ podman create --name ctr1 --env 'ENV*' alpine env
   500  $ podman start --attach ctr1 | grep ENV
   501  ENV1=a
   502  $ podman create --name ctr2 --env 'ENV*=b' alpine env
   503  $ podman start --attach ctr2 | grep ENV
   504  ENV*=b
   505  ```
   506  
   507  ## CONMON
   508  
   509  When Podman starts a container it actually executes the conmon program, which
   510  then executes the OCI Runtime.  Conmon is the container monitor.  It is a small
   511  program whose job is to watch the primary process of the container, and if the
   512  container dies, save the exit code.  It also holds open the tty of the
   513  container, so that it can be attached to later. This is what allows Podman to
   514  run in detached mode (backgrounded), so Podman can exit but conmon continues to
   515  run.  Each container has their own instance of conmon. Conmon waits for the
   516  container to exit, gathers and saves the exit code, and then launches a Podman
   517  process to complete the container cleanup, by shutting down the network and
   518  storage.   For more information about conmon, see the conmon(8) man
   519  page.
   520  
   521  ## FILES
   522  
   523  **/etc/subuid**
   524  **/etc/subgid**
   525  
   526  NOTE: Use the environment variable `TMPDIR` to change the temporary storage location of downloaded container images. Podman defaults to use `/var/tmp`.
   527  
   528  ## SEE ALSO
   529  **[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)**, **[pasta(1)](https://passt.top/builds/latest/web/passt.1.html)**, **[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)**
   530  
   531  ## HISTORY
   532  October 2017, converted from Docker documentation to Podman by Dan Walsh for Podman `<dwalsh@redhat.com>`
   533  
   534  November 2014, updated by Sven Dowideit `<SvenDowideit@home.org.au>`
   535  
   536  September 2014, updated by Sven Dowideit `<SvenDowideit@home.org.au>`
   537  
   538  August 2014, updated by Sven Dowideit `<SvenDowideit@home.org.au>`
   539  
   540  ## FOOTNOTES
   541  <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 needs to 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.