0
Check if a docker container is running
One script reply has been approved by the moderators Verified

Echoes True if a docker container is running and False if not

Created by yassinsiouda74165 567 days ago Viewed 9843 times
0
Submitted by yassinsiouda74165 Bash
Verified 567 days ago
1
container_name="${1:-world}"
2

3
# check if the container exists
4
if docker ps -a | grep -q "$container_name"; then
5
  echo "true"
6
else
7
  echo "false"
8
fi
9