bash - Comment vérifier si docker daemon fonctionne

Mots clés : bashshelldockerbash

meilleur 4 Réponses bash - Comment vérifier si docker daemon fonctionne

vote vote

100

#!/bin/bash #Open Docker, only if is not running if (! docker stats --no-stream ); then   # On Mac OS this would be the terminal command to launch Docker   open /Applications/Docker.app  #Wait until Docker daemon is running and has completed initialisation while (! docker stats --no-stream ); do   # Docker takes a few seconds to initialize   echo "Waiting for Docker to launch..."   sleep 1 done fi  #Start the Container.. 
vote vote

86

$ systemctl status docker 
vote vote

79

pgrep -f docker > /dev/null || echo "starting docker" 
vote vote

61

## check docker is running at all ## based on https://stackoverflow.com/questions/22009364/is-there-a-try-catch-command-in-bash {   ## will throw an error if the docker daemon is not running and jump   ## to the next code chunk        docker ps -q } || {   echo "Docker is not running. Please start docker on your computer"   echo "When docker has finished starting up press [ENTER} to continue"   read } 

Questions similaires