Skip to content

Commit

Permalink
Merge pull request #855 from afbjorklund/clients
Browse files Browse the repository at this point in the history
Add client wrappers for docker and podman, similar to nerdctl wrapper
  • Loading branch information
jandubois authored May 16, 2022
2 parents 234a65c + 6baccd7 commit 8388641
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ binaries: clean \
_output/bin/lima \
_output/bin/limactl \
_output/bin/nerdctl.lima \
_output/bin/docker.lima \
_output/bin/podman.lima \
_output/share/lima/lima-guestagent.Linux-x86_64 \
_output/share/lima/lima-guestagent.Linux-aarch64 \
_output/share/lima/lima-guestagent.Linux-riscv64
Expand All @@ -40,6 +42,14 @@ _output/bin/nerdctl.lima:
mkdir -p _output/bin
cp -a ./cmd/nerdctl.lima $@

_output/bin/docker.lima: ./cmd/docker.lima
@mkdir -p _output/bin
cp -a $^ $@

_output/bin/podman.lima: ./cmd/podman.lima
@mkdir -p _output/bin
cp -a $^ $@

.PHONY: _output/bin/limactl
_output/bin/limactl:
# The hostagent must be compiled with CGO_ENABLED=1 so that net.LookupIP() in the DNS server
Expand Down
18 changes: 18 additions & 0 deletions cmd/docker.lima
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
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')
export DOCKER_HOST
exec "$DOCKER" "$@"
else
export LIMA_INSTANCE
exec lima docker "$@"
fi
18 changes: 18 additions & 0 deletions cmd/podman.lima
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
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')
export CONTAINER_HOST
exec "$PODMAN" --remote "$@"
else
export LIMA_INSTANCE
exec lima podman "$@"
fi

0 comments on commit 8388641

Please sign in to comment.