在CentOS 7和Fedora 33/32/31/30上安装Podman

时间:2020-02-23 14:31:36  来源:igfitidea点击:

本教程将讨论如何在CentOS 7/Fedora 33/32/31/30上安装Podman。 Podman是一个无守护程序的容器引擎,用于在Linux系统上开发,管理和运行OCIContainer。 Docker和Podman之间的主要区别是Podman中没有守护程序。

Podman也使用容器运行时,例如runc,但是启动的容器是podman进程的直接后代。这种架构具有如下优点:

应用的Cgroup或者安全性约束仍然控制着容器:无论我们对podman命令应用的cgroup约束如何,启动的容器都将直接接收相同的约束。可以使用此模型利用systemd的高级功能:可以通过将podman放置在容器中systemd单位文件,因此可以实现更多功能。

以下工具集可以协同工作,以在没有持续运行的守护进程的情况下增强容器的使用.Buildah有助于构建OCI镜像目的是在Docker注册表,Atomic注册表,私有注册表,本地目录和本地OCI上共享/查找容器镜像-layout目录。Podman用于运行容器,而无需守护程序。

在CentOS 7/Fedora 33/32/31/30上安装Podman

可以在Fedora和CentOS上游存储库中使用podman软件包。

CentOS 7:

sudo yum -y install podman

Fedora :

sudo dnf install -y podman

要查看已安装的软件包详细信息,请使用rpm命令。

$rpm -qi podman
Name        : podman
Epoch       : 2
Version     : 2.1.1
Release     : 10.fc33
Architecture: x86_64
Install Date: Wed 28 Oct 2017 09:47:17 PM UTC
Group       : Unspecified
Size        : 46396620
License     : ASL 2.0
Signature   : RSA/SHA256, Sun 04 Oct 2017 11:34:54 PM UTC, Key ID 49fd77499570ff31
Source RPM  : podman-2.1.1-10.fc33.src.rpm
Build Date  : Sun 04 Oct 2017 11:25:22 PM UTC
Build Host  : buildhw-x86-04.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://podman.io/
Bug URL     : https://bugz.fedoraproject.org/podman
Summary     : Manage Pods, Containers and Container Images
Description :
...

安装后,我们可以显示有关主机,当前存储状态和podman的构建的信息。

$podman info
host:
  BuildahVersion: 1.6-dev
  Conmon:
    package: podman-0.12.1.2-2.git9551f6b.el7.centos.x86_64
    path: /usr/libexec/podman/conmon
    version: 'conmon version 1.12.0-dev, commit: b909c9e1a3e8f14d5694a118fb9c0c0325a31d4f-dirty'
  Distribution:
    distribution: '"centos"'
    version: "7"
  MemFree: 461684736
  MemTotal: 3872858112
  OCIRuntime:
    package: runc-1.0.0-59.dev.git2abd837.el7.centos.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.0'
  SwapFree: 0
  SwapTotal: 0
  arch: amd64
  cpus: 2
  hostname: techwiz-app-server
  kernel: 3.10.0-957.10.1.el7.x86_64
  os: linux
  rootless: false
  uptime: 831h 27m 5.82s (Approximately 34.62 days)
insecure registries:
  registries: []
registries:
  registries:
  - registry.access.redhat.com
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.centos.org
store:
  ContainerStore:
    number: 0
  GraphDriverName: overlay
  GraphOptions:
  - overlay.override_kernel_check=true
  GraphRoot: /var/lib/containers/storage
  GraphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
  ImageStore:
    number: 0
  RunRoot: /var/run/containers/storage

尝试拉Alpine Linux镜像。

$podman pull alpine
Trying to pull registry.access.redhat.com/alpine:latest...Failed
Trying to pull docker.io/alpine:latest...Getting image source signatures
Copying blob sha256:e7c96db7181be991f19a9fb6975cdbbd73c65f4a2681348e63a141a2192a5f10
 2.63 MB/2.63 MB [========================================================] 0s
Copying config sha256:055936d3920576da37aa9bc460d70c5f212028bda1c08c0879aedf03d7a66ea1
 1.48 KB/1.48 KB [========================================================] 0s
Writing manifest to image destination
Storing signatures
055936d3920576da37aa9bc460d70c5f212028bda1c08c0879aedf03d7a66ea1

检查下载的图像列表。

$podman images
REPOSITORY                 TAG      IMAGE ID       CREATED       SIZE
docker.io/library/alpine   latest   055936d39205   5 weeks ago   5.8 MB

在CentOS 7/Fedora 32/32/31/30上使用Podman

现在,我们已经在CentOS 7和Fedora系统上安装了podman,接下来的内容是如何使用它。
请查阅

如何使用Podman和Libpod运行Docker容器

使用Podman设置Docker容器注册表并让SSL加密

使用Podman将容器镜像发布到Docker Hub /镜像注册表