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은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동