← 返回命令列表

Linux command

podman-exec 命令

文本

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

常用示例

Execute command in container

podman exec [container] [command]

Interactive shell

podman exec -it [container] /bin/bash

Run as specific user

podman exec -u [root] [container] [command]

Set environment variable

podman exec -e [VAR=value] [container] [command]

说明

podman exec runs a command inside a running container. It's essential for debugging, maintenance, and interacting with container processes.

参数

-i, --interactive
Keep stdin open.
-t, --tty
Allocate TTY.
-u, --user _user_
Run as user.
-e, --env _var=val_
Set environment variable.
-w, --workdir _dir_
Working directory.
-d, --detach
Run in background. Prints the exec session ID and exits immediately.
--detach-keys _sequence_
Key sequence for detaching from the container (default: ctrl-p,ctrl-q).
--env-file _file_
Read environment variables from a line-delimited file.
-l, --latest
Use the most recently created container instead of specifying a name or ID.
--preserve-fds _N_
Pass N additional file descriptors (beyond stdin/stdout/stderr) to the process.
--privileged
Give extended privileges to the command.

FAQ

What is the podman-exec command used for?

podman exec runs a command inside a running container. It's essential for debugging, maintenance, and interacting with container processes.

How do I run a basic podman-exec example?

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

What does -i, --interactive do in podman-exec?

Keep stdin open.