mirror of
https://github.com/docker/docker-bench-security.git
synced 2024-11-01 08:31:44 +01:00
should fix the: Error response from daemon: This node is not a swarm manager. issue
This commit is contained in:
parent
412f514bb4
commit
0dc2d2b1e6
1 changed files with 12 additions and 10 deletions
|
@ -596,17 +596,19 @@ check_5_14() {
|
||||||
maxretry_unset_containers=""
|
maxretry_unset_containers=""
|
||||||
for c in $containers; do
|
for c in $containers; do
|
||||||
container_name=$(docker inspect "$c" --format '{{.Name}}')
|
container_name=$(docker inspect "$c" --format '{{.Name}}')
|
||||||
for s in $(docker service ls --format '{{.Name}}'); do
|
if [ "$(docker info --format '{{.Swarm.LocalNodeState}}')" = "active" ]; then
|
||||||
if echo $container_name | grep -q "$s"; then
|
for s in $(docker service ls --format '{{.Name}}'); do
|
||||||
task_id=$(docker inspect "$c" --format '{{.Name}}' | awk -F '.' '{print $NF}')
|
if echo $container_name | grep -q "$s"; then
|
||||||
# a container name could arbitrary include a service one: it belongs to a service (created by Docker
|
task_id=$(docker inspect "$c" --format '{{.Name}}' | awk -F '.' '{print $NF}')
|
||||||
# as part of the service), if the container task ID matches one of the task IDs of the service.
|
# a container name could arbitrary include a service one: it belongs to a service (created by Docker
|
||||||
if docker service ps --no-trunc "$s" --format '{{.ID}}' | grep -q "$task_id"; then
|
# as part of the service), if the container task ID matches one of the task IDs of the service.
|
||||||
spolicy=$(docker inspect --format MaxAttempts='{{ .Spec.TaskTemplate.RestartPolicy.MaxAttempts }}' "$s")
|
if docker service ps --no-trunc "$s" --format '{{.ID}}' | grep -q "$task_id"; then
|
||||||
break
|
spolicy=$(docker inspect --format MaxAttempts='{{ .Spec.TaskTemplate.RestartPolicy.MaxAttempts }}' "$s")
|
||||||
|
break
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
done
|
fi
|
||||||
cpolicy=$(docker inspect --format MaximumRetryCount='{{ .HostConfig.RestartPolicy.MaximumRetryCount }}' "$c")
|
cpolicy=$(docker inspect --format MaximumRetryCount='{{ .HostConfig.RestartPolicy.MaximumRetryCount }}' "$c")
|
||||||
|
|
||||||
if [ "$cpolicy" != "MaximumRetryCount=5" ] && [ "$spolicy" != "MaxAttempts=5" ]; then
|
if [ "$cpolicy" != "MaximumRetryCount=5" ] && [ "$spolicy" != "MaxAttempts=5" ]; then
|
||||||
|
|
Loading…
Reference in a new issue