[CONTAINER] เจ้า Podman มันดู Log อย่างไร ?

หลายคนหากใช้เจ้าตัว Podman มาสักพัก อาจจะเกิดปัญหา เช่น Container ดับแบบไม่มีสาเหตุ เป็นต้น นอกจากตัว Log ของ Application ที่ได้เราได้พัฒนาแล้ว ฝั่งของ Podman เองก็มี Log เหมือนกันครับ

ตรวจสอบ Log ของ Container

  • ใช้คำสั่ง podman logs
  • รูปแบบคำสั่ง
podman logs [options] [container… (container id หรือ container name ก็ได้)]
  • ตัวอย่างการใช้งาน : ลองดึง Log ล่าสุด 10 row จาก Container ชื่อ wmsl-app-server
podman logs -f --tail 10  wmsl-app-service
  • ตัวอย่างการใช้งาน : ลอง Export Log ของ Container wmsl-app-server ลง Text File สามารถใช้คำสั่งได้ ดังนี้
podman logs  wmsl-app-service >> logPodman.txt
  • จากนั้นสามารถ FTP เข้าไป ดึง Log File (logPodman.txt) จาก Server ออกมาได้ครับ

ตรวจสอบ Log ของ Podman

  • บางครั้งเราอยากรู้ว่าตัว Podman เองมันมีปัญหาอะไร หรือ เปล่า ก็สามารถสำหรับ Log Level ให้มันได้ครับ โดยมี Level ที่เป็นไปได้ ได้แก่ debug, info, warn, error (ค่า Default)
  • สำหรับคำสั่งในการกำหนดเพิ่ม Parameter --log-level เข้าไปครับ
  • ตัวอย่างการใช้ ตอน Pull Image (อันนี้ต้อง Subscription RedHat หรือ เป็น RedHat Developer ก่อนครับ) โดยใช้คำสั่ง ดังนี้
podman --log-level=debug pull registry.redhat.io/rhel8/support-tools
...
DEBU[0000] Using registries.d directory /etc/containers/registries.d for sigstore configuration
DEBU[0000]  Using "docker" namespace registry.redhat.io
DEBU[0000]   Using https://registry.redhat.io/containers/sigstore
...
  • ตัวอย่างการใช้ ตอน Run Container ครับ
podman run --log-level=debug -it -p 27017:27017 mongodb  
...    
INFO[0000] podman filtering at log level debug          
DEBU[0000] Called run.PersistentPreRunE(podman run --log-level=debug -it -p 27017:27017 mongo) 
DEBU[0000] Ignoring libpod.conf EventsLogger setting "/home/smit/.config/containers/containers.conf". Use "journald" if you want to change this setting and remove libpod.conf files. 
WARN[0000] The cgroupv2 manager is set to systemd but there is no systemd user session available 
...  

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts to your email.