Skip to content

Instantly share code, notes, and snippets.

@yoandresaav
Created August 9, 2024 16:39
Show Gist options
  • Save yoandresaav/1b8bfc33c72f41e1d9f0a260926af87c to your computer and use it in GitHub Desktop.
Save yoandresaav/1b8bfc33c72f41e1d9f0a260926af87c to your computer and use it in GitHub Desktop.
If Docker is not running, Run Docker
#!/bin/bash
# Check if docker is running and start it if it's not
if docker info > /dev/null 2>&1; then
echo "Docker is running"
else
echo "Docker is not running"
open /Applications/Docker.app
echo "Docker is starting"
while ! docker info > /dev/null 2>&1; do
echo -n "."
sleep 1
done
echo "Docker is running"
fi
# Stop all running containers
echo "Stopping all docker containers"
docker stop $(docker ps -a -q)
# Up all containers
echo "Running docker-compose up"
docker-compose up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment