mirror of
https://github.com/lima-vm/lima.git
synced 2026-10-28 11:44:35 +08:00
The old style template://name URLs are malformed because they do not contain a valid AUTHORITY (host name), but treat the host name as part of the path. They are still fully supported, but will emit a warning. Signed-off-by: Jan Dubois <jan.dubois@suse.com>
26 lines
898 B
Bash
Executable File
26 lines
898 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
# Environment Variables
|
|
# LIMA_INSTANCE: Specifies the name of the Lima instance to use. Default is "docker".
|
|
|
|
: "${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 create --name=$LIMA_INSTANCE template:docker\` to create a new instance" >&2
|
|
exit 1
|
|
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
|
|
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing 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')
|
|
export DOCKER_HOST
|
|
exec "$DOCKER" "$@"
|
|
else
|
|
export LIMA_INSTANCE
|
|
exec lima docker "$@"
|
|
fi
|