5.2. 在主机的容器中运行命令

使用 podman run 命令显示容器的操作系统的类型。

先决条件

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

流程

  1. 使用 cat /etc/os-release 命令显示基于 registry.access.redhat.com/ubi9/ubi 容器镜像的容器类型:

    $ podman run --rm registry.access.redhat.com/ubi9/ubi cat /etc/os-release
    NAME="Red Hat Enterprise Linux"
    ...
    ID="rhel"
    ...
    HOME_URL="https://www.redhat.com/"
    BUG_REPORT_URL="https://bugzilla.redhat.com/"
    
    REDHAT_BUGZILLA_PRODUCT=" Red Hat Enterprise Linux 9"
    ...
  2. 可选:列出所有容器。

    $ podman ps
    CONTAINER ID  IMAGE   COMMAND  CREATED  STATUS  PORTS   NAMES

    由于 --rm 选项,您应该看不到任何容器。容器已被删除。

其他资源

  • podman-run 手册页