Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Containerization and Virtualization

This category covers container runtimes, container image tools, and other virtualization-related tools.

Container Runtimes

Podman

Podman 是一个现代化的、无守护进程的容器引擎,它提供了一个与 Docker 兼容的命令行界面,使熟悉 Docker 的用户能够轻松过渡。

安装

要安装 Podman,请添加以下行到 configuration.nix

virtualisation.podman.enable = true;

已验证的使用情况

podman run

podman run在新容器中运行命令。

# Start a container, execute a command, and then exit
podman run --name=c1 docker.io/library/alpine ls /etc

# Start a container and attach to an interactive shell
podman run -it docker.io/library/alpine
podman image

podman image 管理本地镜像。

# List downloaded images
podman image ls
podman ps

podman ps列出容器。

# Show the status of all containers (including exited ones)
podman ps -a
podman rm

podman rm删除一个或多个容器。

# Remove a container named foo
podman rm foo

Container Image Tools

Skopeo

Skopeo inspects and copies container images without a daemon.

安装

environment.systemPackages = [ pkgs.skopeo ];

已验证的使用情况

# Inspect a remote image
skopeo inspect docker://docker.io/library/alpine:latest

# List all tags for a repository
skopeo list-tags docker://docker.io/library/alpine