← 返回命令列表

Linux command

nerdctl 命令

文本

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

常用示例

List all containers

nerdctl ps -a

Run

nerdctl run --name [container_name] [image]

Start or stop

nerdctl start [container_name]

Example

nerdctl stop [container_name]

Pull

nerdctl pull [image]

List downloaded images

nerdctl images

Execute

nerdctl exec -it [container_name] sh

Remove

nerdctl rm [container1] [container2]

View logs

nerdctl logs -f [container_name]

说明

nerdctl is a Docker-compatible CLI for containerd, the industry-standard container runtime. It provides familiar Docker commands while leveraging containerd's capabilities, including rootless containers and lazy-pulling images. The tool supports Docker Compose files, Dockerfile builds, and most Docker CLI syntax. It can work with both Docker and containerd images and registries.

参数

-a, --all
Show all containers (default: running only)
-i, --interactive
Keep STDIN open
-t, --tty
Allocate a pseudo-TTY
-d, --detach
Run container in background
--name _name_
Assign name to container
-p, --publish _port_
Publish container port (host:container)
-v, --volume _mount_
Bind mount a volume (host:container)
-f, --follow
Follow log output
--rm
Remove container after exit
-e, --env _VAR=VALUE_
Set environment variable
--network _network_
Connect to a network

FAQ

What is the nerdctl command used for?

nerdctl is a Docker-compatible CLI for containerd, the industry-standard container runtime. It provides familiar Docker commands while leveraging containerd's capabilities, including rootless containers and lazy-pulling images. The tool supports Docker Compose files, Dockerfile builds, and most Docker CLI syntax. It can work with both Docker and containerd images and registries.

How do I run a basic nerdctl example?

Run `nerdctl ps -a` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --all do in nerdctl?

Show all containers (default: running only)