例如,只顯示那些運行超過 10 分鐘的容器。
docker container ls -q --format '{{.Names}}' --filter status=running
uj5u.com熱心網友回復:
首先,您需要獲取容器創建日期時間,然后將其與當前日期進行比較
#!/bin/bash
# Date 1
container_date=$(docker inspect --format='{{.State.StartedAt}}' CONTAINER_NAME)
# Compute the seconds since epoch for date 1
t1=$(date --date="$container_date" %s)
# Date 2 : Current date
current_date=$(date %Y-%m-%d\ %H:%M:%S)
# Compute the seconds since epoch for date 2
t2=$(date --date="$current_date" %s)
# Compute the difference in dates in seconds
let "tDiff=$t2-$t1"
# Compute the approximate hour difference
let "hDiff=$tDiff/3600"
echo "Approx hour diff b/w $container_date & $current_date= $hDiff"
參考鏈接
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/457920.html
標籤:码头工人
上一篇:為什么簡單Docker nginx配置上的連接被拒絕錯誤?
下一篇:Symfony,Docker容器fpm,apache:找不到驅動程式[doctrine:database:create]
