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 334 days ago Viewed 6057 times
0
Submitted by yassinsiouda74165 Bash
Verified 334 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