Docker
TMA-DOCKER-5.15
Ensure that the 'on-failure' container restart policy is set to '5'
НискаНиво 1Аутоматскаdocker
Опис
Restart policy 'always' (or on-failure with unlimited retries) can hide failures and turn a crashing container into a resource drain; on-failure with at most 5 retries is recommended. Flags always, unless-stopped and on-failure with 0 or more than 5 retries. The audit inspects every running container (docker ps -q) and prints the offending names; a host with no running containers is compliant.
Како се проверава
Метод провере: Команда љуске
shell
ids=$(docker ps -q) || exit 1; [ -z "$ids" ] && { echo compliant; exit 0; }; out=$(docker inspect --format '{{.Name}} {{.HostConfig.RestartPolicy.Name}} {{.HostConfig.RestartPolicy.MaximumRetryCount}}' $ids) || exit 1; bad=$(printf '%s\n' "$out" | awk '$2=="always" || $2=="unless-stopped" || ($2=="on-failure" && ($3+0==0 || $3+0>5)){print $1" "$2":"$3}'); [ -z "$bad" ] && echo compliant || printf '%s\n' "$bad"- Очекивани излаз
compliant
Како се исправља
Метод исправке: Смерница или закрпа инфраструктуре
Redeploy with --restart=on-failure:5 (compose: 'restart: on-failure:5') or update in place: docker update --restart=on-failure:5 <container>.
Својства
- Оперативни системи
- Било који
- Ознаке
- dockerruntime
- Референца
- CIS Docker Benchmark v1.9.0 - 5.15 Ensure that the 'on-failure' container restart policy is set to '5'
Проверите овај рачунар
Покрените ово на рачунару за који имате дозволу за проверу. Скенирање ради у режиму само за читање.
shell
tmaegis scan --target docker