I am writing a shell script in which I am installing docker on Mac through terminal. I am able to install through brew cask install docker
. Now it is GUI based docker which wait for user event to continue. Now in my shell script I want hold the execution until docker is started and running. I have found a nice script which checks if docker is running or not. I am able to check it though as below.
#!/bin/bash
rep=$(curl -s --unix-socket /var/run/docker.sock http://ping > /dev/null)
status=$?
if [ "$status" == "7" ]; then
echo 'not connected'
exit 1
fi
echo 'connected'
exit 0
I have tried to it put in a loop so that until status is 0 it should check again and again and hold the exception. I have no experience in shell scripting but tried a way to run but failed to do . how can I achieve this.
My script
#!/bin/bash
status=0
test() {
rep=$(curl -s --unix-socket /var/run/docker.sock http://ping > /dev/null)
status=$?
}
checkDocker() {
while [ "$status" == "7" ]
do
echo waiting docker to start
test
done
}