From 052f79ea329c428e38ced4d7d8bc3e89bc1bed8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Thu, 12 May 2022 19:50:13 +0200 Subject: [PATCH] Exit if instance does not exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders F Björklund --- cmd/docker.lima | 4 ++++ cmd/podman.lima | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/docker.lima b/cmd/docker.lima index 17ae295426dd..5f79ca5ff51f 100755 --- a/cmd/docker.lima +++ b/cmd/docker.lima @@ -3,6 +3,10 @@ set -eu : "${LIMA_INSTANCE:=docker}" : "${DOCKER:=docker}" +if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then + echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl start --name=$LIMA_INSTANCE template://docker\` to create a new instance" >&2 + exit 1 +fi DOCKER=$(command -v "$DOCKER" || true) if [ -n "$DOCKER" ]; then DOCKER_HOST=$(limactl list "$LIMA_INSTANCE" --format 'unix://{{.Dir}}/sock/docker.sock') diff --git a/cmd/podman.lima b/cmd/podman.lima index 0aaaa5443b05..a5dfed85b446 100755 --- a/cmd/podman.lima +++ b/cmd/podman.lima @@ -3,6 +3,10 @@ set -eu : "${LIMA_INSTANCE:=podman}" : "${PODMAN:=podman}" +if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then + echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl start --name=$LIMA_INSTANCE template://podman\` to create a new instance" >&2 + exit 1 +fi PODMAN=$(command -v "$PODMAN" || true) if [ -n "$PODMAN" ]; then CONTAINER_HOST=$(limactl list "$LIMA_INSTANCE" --format 'unix://{{.Dir}}/sock/podman.sock')