Skip to content

Commit afa5727

Browse files
committed
🏴‍☠️ Compose sails adjusted: autodetects the right docker command, no more scurvy flags
1 parent ee5160c commit afa5727

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scripts/compose_restart.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,23 @@ cd "$PROJECT_DIR" || {
2626
# Extract the last part of the directory path to use as a human-readable name
2727
PROJECT_NAME=$(basename "$PROJECT_DIR")
2828

29+
# Detect whether to use 'docker compose' or 'docker-compose'
30+
if docker compose version >/dev/null 2>&1; then
31+
COMPOSE_CMD="docker compose"
32+
elif command -v docker-compose >/dev/null 2>&1; then
33+
COMPOSE_CMD="docker-compose"
34+
else
35+
echo "ERROR: Neither 'docker compose' nor 'docker-compose' was found on this system."
36+
exit 1
37+
fi
38+
2939
# Tear down the running stack, including named volumes
3040
echo "Stopping and removing current containers and volumes for '$PROJECT_NAME'..."
31-
docker compose down --volumes
41+
$COMPOSE_CMD down -v
3242

3343
# Rebuild and start the stack in detached mode
3444
echo "Rebuilding and starting containers for '$PROJECT_NAME' with enforced startup order..."
35-
docker compose up -d
45+
$COMPOSE_CMD up -d
3646

3747
# Report success
3848
echo "'$PROJECT_NAME' stack restarted successfully."

0 commit comments

Comments
 (0)