When I create containers I\'m specifying a restart policy, but this is not shown in docker ps
, and it doesn\'t appear any format string shows this either.
D
I did this little script to check all the containers and their policy:
#!/usr/bin/env bash
#Script to check the restart policy of the containers
readarray -t CONTAINERS < <(docker ps -a | grep -v NAMES | awk '{print $NF}')
for item in "${CONTAINERS[@]}"; do
#Hard-Bash way
#data=$(docker inspect "${item}" | grep -A 1 RestartPolicy | awk -F '"' '{print $4}' | tail -n 1)
#Docker-pr0 way
data=$(docker inspect -f "{{ .HostConfig.RestartPolicy.Name }}" "${item}")
echo "Container: ${item} / RestartPolicy: ${data}"
done
Hope it helps to somebody!