Red Hat Training

A Red Hat training course is available for RHEL 8

21.2. 명령줄을 사용하여 상태 점검 수행

명령줄에서 컨테이너를 생성할 때 상태 점검을 설정할 수 있습니다.

사전 요구 사항

  • container-tools 모듈이 설치되어 있습니다.

절차

  1. 상태 점검을 정의합니다.

    $ podman run -dt --name=hc-container -p 8080:8080 --health-cmd='curl http://localhost:8080 || exit 1' --health-interval=0 registry.access.redhat.com/ubi8/httpd-24
    • --health-cmd 옵션은 컨테이너에 대한 상태 점검 명령을 설정합니다.
    • 값이 0인 --health-interval=0 옵션은 상태 점검을 수동으로 실행하려고 함을 나타냅니다.
  2. hc-container 컨테이너의 상태를 확인합니다.

    • podman inspect 명령을 사용합니다.

      $ podman inspect --format='{{json .State.Health.Status}}' hc-container
      healthy
    • podman ps 명령을 사용합니다.

      $ podman ps
      CONTAINER ID  IMAGE                 COMMAND               CREATED      STATUS          PORTS       NAMES
      a680c6919fe  localhost/hc-container:latest  /usr/bin/run-http...  2 minutes ago  Up 2 minutes (healthy) hc-container
    • podman healthcheck run 명령을 사용합니다.

      $ podman healthcheck run hc-container
      healthy