本文将引导你在Debian 10(Buster)和Debian 9(Stretch)操作系统上安装Podman。Podman也使用容器运行时,例如runc,但启动的容器是podman进程的直接后代,它是libpod库的一部分,参考安装以使用Podman可以在非root权限中运行Linux容器。
一、更新系统及安装相关依赖项 1、更新系统 更新包索引: sudo apt -y update && sudo apt -y upgrade 2、安装先决条件 在我们的安装中,我们将从源代码构建包,通过运行下一个命令安装所需的所有依赖项: sudo apt -y install \ gcc \ make \ cmake \ git \ btrfs-progs \ golang-go \ go-md2man \ iptables \ libassuan-dev \ libc6-dev \ libdevmapper-dev \ libglib2.0-dev \ libgpgme-dev \ libgpg-error-dev \ libostree-dev \ libprotobuf-dev \ libprotobuf-c-dev \ libseccomp-dev \ libselinux1-dev \ libsystemd-dev \ pkg-config \ runc \ uidmap \ libapparmor-dev
二、安装conmon及安装CNI插件、设置CNI网络 1、安装conmon 最新版本的conmon将安装在系统上,Conmon用于监视OCI运行时: git clone https://github.com/containers/conmon cd conmon make sudo make podman sudo cp /usr/local/libexec/podman/conmon /usr/local/bin/ 2、安装CNI插件 运行以下命令以确保在系统上安装CNI插件: git clone https://github.com/containernetworking/plugins.git $GOPATH/src/github.com/containernetworking/plugins cd $GOPATH/src/github.com/containernetworking/plugins ./build_linux.sh sudo mkdir -p /usr/libexec/cni sudo cp bin/* /usr/libexec/cni 3、设置CNI网络: 安装CNI命令后,添加配置文件: sudo mkdir -p /etc/cni/net.d curl -qsSL https://raw.githubusercontent.com/containers/libpod/master/cni/87-podman-bridge.conflist | sudo tee /etc/cni/net.d/99-loopback.conf
三、配置文件 我们需要手动添加配置文件,例如注册表和策略: sudo mkdir -p /etc/containers sudo curl https://raw.githubusercontent.com/projectatomic/registries/master/registries.fedora -o /etc/containers/registries.conf sudo curl https://raw.githubusercontent.com/containers/skopeo/master/default-policy.json -o /etc/containers/policy.json
四、安装Podman 我们现在可以从Github下载Podman源代码并构建二进制应用程序: git clone https://github.com/containers/libpod/ $GOPATH/src/github.com/containers/libpod cd $GOPATH/src/github.com/containers/libpod make sudo make install 然后检查podman版本: $ podman version Version: 1.4.5-dev RemoteAPI Version: 1 Go Version: go1.11.6 OS/Arch: linux/amd64 你可以显示有关主机,当前存储统计信息和podman构建的信息: $ podman info host: BuildahVersion: 1.9.2 Conmon: package: Unknown path: /usr/local/bin/conmon version: 'conmon version 1.0.1-dev, commit: 8392df88fba944510b51c7d5b92aa745a15863f8' Distribution: distribution: debian version: "10" MemFree: 6179495936 MemTotal: 8167223296 OCIRuntime: package: 'runc: /usr/sbin/runc' path: /usr/sbin/runc version: |- runc version 1.0.0~rc6+dfsg1 commit: 1.0.0~rc6+dfsg1-3 spec: 1.0.1 SwapFree: 0 SwapTotal: 0 arch: amd64 cpus: 2 eventlogger: journald hostname: debian10 kernel: 4.19.0-5-amd64 os: linux rootless: false uptime: 13m 44.64s registries: blocked: null insecure: null search: - docker.io - registry.fedoraproject.org - registry.access.redhat.com store: ConfigFile: /etc/containers/storage.conf ContainerStore: number: 0 GraphDriverName: overlay GraphOptions: null GraphRoot: /var/lib/containers/storage GraphStatus: Backing Filesystem: extfs Native Overlay Diff: "true" Supports d_type: "true" Using metacopy: "false" ImageStore: number: 0 RunRoot: /var/run/containers/storage VolumePath: /var/lib/containers/storage/volumes 主要配置文件: /etc/containers/registries.conf-配置文件,指定在完成不包含注册表或域部分的映像名称时应查询哪些容器注册表。 /etc/containers/mounts.conf-指定在执行podman run或podman构建命令时自动挂载到容器内的卷装入目录。
五、在Debian上安装测试Podman Pull Alpine docker image: $ podman pull alpine
运行docker容器: $ podman images $ podman run -ti b7b28af77ffe /bin/sh
现在我们已经确认可以创建一个容器,让我们删除它: # podman rm -f `podman ps -aq`
相关主题 |