Skip to content

Commit 8388641

Browse files
authored
Merge pull request #855 from afbjorklund/clients
Add client wrappers for docker and podman, similar to nerdctl wrapper
2 parents 234a65c + 6baccd7 commit 8388641

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ binaries: clean \
2121
_output/bin/lima \
2222
_output/bin/limactl \
2323
_output/bin/nerdctl.lima \
24+
_output/bin/docker.lima \
25+
_output/bin/podman.lima \
2426
_output/share/lima/lima-guestagent.Linux-x86_64 \
2527
_output/share/lima/lima-guestagent.Linux-aarch64 \
2628
_output/share/lima/lima-guestagent.Linux-riscv64
@@ -40,6 +42,14 @@ _output/bin/nerdctl.lima:
4042
mkdir -p _output/bin
4143
cp -a ./cmd/nerdctl.lima $@
4244

45+
_output/bin/docker.lima: ./cmd/docker.lima
46+
@mkdir -p _output/bin
47+
cp -a $^ $@
48+
49+
_output/bin/podman.lima: ./cmd/podman.lima
50+
@mkdir -p _output/bin
51+
cp -a $^ $@
52+
4353
.PHONY: _output/bin/limactl
4454
_output/bin/limactl:
4555
# The hostagent must be compiled with CGO_ENABLED=1 so that net.LookupIP() in the DNS server

cmd/docker.lima

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
set -eu
3+
: "${LIMA_INSTANCE:=docker}"
4+
: "${DOCKER:=docker}"
5+
6+
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
7+
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl start --name=$LIMA_INSTANCE template://docker\` to create a new instance" >&2
8+
exit 1
9+
fi
10+
DOCKER=$(command -v "$DOCKER" || true)
11+
if [ -n "$DOCKER" ]; then
12+
DOCKER_HOST=$(limactl list "$LIMA_INSTANCE" --format 'unix://{{.Dir}}/sock/docker.sock')
13+
export DOCKER_HOST
14+
exec "$DOCKER" "$@"
15+
else
16+
export LIMA_INSTANCE
17+
exec lima docker "$@"
18+
fi

cmd/podman.lima

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
set -eu
3+
: "${LIMA_INSTANCE:=podman}"
4+
: "${PODMAN:=podman}"
5+
6+
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
7+
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl start --name=$LIMA_INSTANCE template://podman\` to create a new instance" >&2
8+
exit 1
9+
fi
10+
PODMAN=$(command -v "$PODMAN" || true)
11+
if [ -n "$PODMAN" ]; then
12+
CONTAINER_HOST=$(limactl list "$LIMA_INSTANCE" --format 'unix://{{.Dir}}/sock/podman.sock')
13+
export CONTAINER_HOST
14+
exec "$PODMAN" --remote "$@"
15+
else
16+
export LIMA_INSTANCE
17+
exec lima podman "$@"
18+
fi

0 commit comments

Comments
 (0)