搜索

6.3. 运行带有 runc 和 crun 的容器

download PDF

有了 runc 或 crun,容器可以使用捆绑包进行配置。容器的捆绑包是一个目录,其中包含一个名为 config.json 的规范文件和根文件系统。根文件系统包含容器的内容。

注意

<runtime> 可以是 crun 或 runc。

先决条件

  • container-tools 元数据包已安装。

流程

  1. 拉取 registry.access.redhat.com/ubi9/ubi 容器镜像:

    # podman pull registry.access.redhat.com/ubi9/ubi
  2. registry.access.redhat.com/ubi9/ubi 镜像导出到 rhel.tar 归档:

    # podman export $(podman create registry.access.redhat.com/ubi9/ubi) > rhel.tar
  3. 创建 bundle/rootfs 目录:

    # mkdir -p bundle/rootfs
  4. rhel.tar 归档解压到 bundle/rootfs 目录中:

    # tar -C bundle/rootfs -xf rhel.tar
  5. 为捆绑包创建一个名为 config.json 的新规范文件:

    # <runtime> spec -b bundle
    • -b 选项指定捆绑包目录。默认值为当前目录。
  6. 可选:更改设置:

    # vi bundle/config.json
  7. 为捆绑包创建一个名为 myubi 的容器实例:

    # <runtime> create -b bundle/ myubi
  8. 启动 myubi 容器:

    # <runtime> start myubi
注意

容器实例的名称对于主机来说必须是唯一的。要启动容器的一个新实例:# <runtime> start <container_name>

验证

  • 列出由 <runtime> 启动的容器:

    # <runtime> list
    ID               PID         STATUS      BUNDLE            CREATED                          OWNER
    myubi            0           stopped     /root/bundle      2021-09-14T09:52:26.659714605Z   root

其他资源

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.