Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client wrappers for docker and podman, similar to nerdctl wrapper #855

Merged
merged 1 commit into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"
afbjorklund marked this conversation as resolved.
Show resolved Hide resolved
: "${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