5.11. Executing commands inside a running container


Use the podman exec command to execute a command in a running container and investigate that container. The reason for using the podman exec command instead of podman run command is that you can investigate the running container without interrupting the container activity.

Prerequisites

  • The container-tools meta-package is installed.
  • The container is running.

Procedure

  1. Execute the rpm -qa command inside the my-support-tools container to list all installed packages:

    $ podman exec -it my-support-tools rpm -qa
    gpg-pubkey-fd431d51-4ae0493b
    gpg-pubkey-5a6340b3-6229229e
    libgcc-11.5.0-2.el9.x86_64
    setup-2.13.7-10.el9.noarch
    ...
  2. Execute a /bin/bash command in the my-support-tools container:

    $ podman exec -it my-support-tools /bin/bash
  3. Install the procps-ng package containing a set of system utilities (for example ps, top, uptime, and so on):

    # dnf install procps-ng
  4. Inspect the container:

    • To list every process on the system:

      # ps -ef
      UID          PID    PPID  C STIME TTY          TIME CMD
      root           8       0  0 11:07 pts/0    00:00:00 /bin/bash
      root          47       8  0 11:13 pts/0    00:00:00 ps -ef
    • To display file system disk space usage:

      # df -h
      Filesystem      Size  Used Avail Use% Mounted on
      tmpfs           6.3G  448K  6.3G   1% /etc/hosts
      shm              63M     0   63M   0% /dev/shm
      overlay         953G   76G  877G   8% /
      tmpfs            64M     0   64M   0% /dev
      devtmpfs        4.0M     0  4.0M   0% /dev/tty
      ...
    • To display system information:

      # uname -r
      6.13.4-200.fc41.x86_64
    • To display amount of free and used memory in megabytes:

      # free --mega
      total        used        free      shared  buff/cache   available
      Mem:       2818         615        1183          12         1020        1957
      Swap:      3124           0        3124
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る