Fix the bug that a container may not have ps command

This commit is contained in:
Nitro Cao 2021-09-01 11:03:50 +08:00
commit fd9ad44344
No known key found for this signature in database
GPG key ID: CC98954D729E9CD6
2 changed files with 2 additions and 2 deletions

View file

@ -254,7 +254,7 @@ check_5_6() {
printcheck=0
for c in $containers; do
processes=$(docker exec "$c" ps -el 2>/dev/null | grep -c sshd | awk '{print $1}')
processes=$(docker inspect "$c" --format '{{ .State.Pid }}' 2>/dev/null | xargs pgrep -a -P 2>/dev/null | grep -c sshd | awk '{print $1}')
if [ "$processes" -ge 1 ]; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then