← 返回命令列表

Linux command

podman-run 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run a container

podman run [image]

Run interactively

podman run -it [image] [/bin/bash]

Run in background

podman run -d [image]

Run with port mapping

podman run -p [8080:80] [image]

Run with volume mount

podman run -v [/host/path:/container/path] [image]

Run with name

podman run --name [mycontainer] [image]

Run with environment variable

podman run -e [VAR=value] [image]

Run and auto-remove on exit

podman run --rm -it [image] [command]

Run with custom network

podman run --network [network_name] [image]

说明

podman run creates and starts a new container from a specified image. It is the primary command for launching containers, supporting interactive sessions (-it), background execution (-d), port mapping (-p), volume mounts (-v), and environment variables (-e). The --rm flag automatically removes the container when it exits. The --name option assigns a human-readable name. By default, Podman runs containers rootlessly without requiring a daemon, making it a drop-in replacement for docker run.

参数

-it
Interactive terminal.
-d, --detach
Run in background.
-p, --publish _PORT_
Port mapping.
-v, --volume _MOUNT_
Volume mount.
--name _NAME_
Container name.
-e, --env _VAR_
Environment variable.
--rm
Remove container after exit.
--network _MODE_
Set network mode (bridge, host, none, or custom network name).
--restart _POLICY_
Restart policy (no, on-failure:max, always, unless-stopped).
-w, --workdir _DIR_
Working directory inside the container.
--user _USER_
Run as specified user (name or UID:GID).
--cap-add _CAP_
Add Linux capabilities.
--cap-drop _CAP_
Drop Linux capabilities.
--entrypoint _CMD_
Override image entrypoint.
--label _KEY=VALUE_
Set metadata label on container.

FAQ

What is the podman-run command used for?

podman run creates and starts a new container from a specified image. It is the primary command for launching containers, supporting interactive sessions (-it), background execution (-d), port mapping (-p), volume mounts (-v), and environment variables (-e). The --rm flag automatically removes the container when it exits. The --name option assigns a human-readable name. By default, Podman runs containers rootlessly without requiring a daemon, making it a drop-in replacement for docker run.

How do I run a basic podman-run example?

Run `podman run [image]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -it do in podman-run?

Interactive terminal.