Last active
May 3, 2023 09:48
-
-
Save Hermsi1337/cae623b87b2070431c63cf0b12b54a8c to your computer and use it in GitHub Desktop.
Run docker-rootful on Lima
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example to use Docker instead of containerd & nerdctl | |
# $ limactl start ./docker.yaml | |
# $ limactl shell docker docker run -it -v $HOME:$HOME --rm alpine | |
# To run `docker` on the host (assumes docker-cli is installed): | |
# $ export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock') | |
# $ docker ... | |
# This example requires Lima v0.8.0 or later | |
images: | |
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. | |
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20220420/ubuntu-22.04-server-cloudimg-amd64.img" | |
arch: "x86_64" | |
digest: "sha256:de5e632e17b8965f2baf4ea6d2b824788e154d9a65df4fd419ec4019898e15cd" | |
- location: "https://cloud-images.ubuntu.com/releases/22.04/release-20220420/ubuntu-22.04-server-cloudimg-arm64.img" | |
arch: "aarch64" | |
digest: "sha256:66224c7fed99ff5a5539eda406c87bbfefe8af6ff6b47d92df3187832b5b5d4f" | |
# Fallback to the latest release image. | |
# Hint: run `limactl prune` to invalidate the cache | |
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img" | |
arch: "x86_64" | |
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img" | |
arch: "aarch64" | |
mounts: | |
- location: "~" | |
writable: true | |
# 9p: | |
# cache: "mmap" | |
- location: "/tmp/lima" | |
writable: true | |
mountType: "reverse-sshfs" | |
# containerd is managed by Docker, not by Lima, so the values are set to false here. | |
containerd: | |
system: false | |
user: false | |
provision: | |
- mode: system | |
# This script defines the host.docker.internal hostname when hostResolver is disabled. | |
# It is also needed for lima 0.8.2 and earlier, which does not support hostResolver.hosts. | |
# Names defined in /etc/hosts inside the VM are not resolved inside containers when | |
# using the hostResolver; use hostResolver.hosts instead (requires lima 0.8.3 or later). | |
script: | | |
#!/bin/sh | |
sed -i 's/host.lima.internal.*/host.lima.internal host.docker.internal/' /etc/hosts | |
- mode: system | |
script: | | |
#!/bin/bash | |
set -eux -o pipefail | |
command -v docker >/dev/null 2>&1 && exit 0 | |
export DEBIAN_FRONTEND=noninteractive | |
curl -fsSL https://get.docker.com | bash | |
- mode: system | |
script: | | |
#!/bin/bash | |
set -eux -o pipefail | |
docker run --privileged --rm tonistiigi/binfmt --install all | |
- mode: system | |
script: | | |
#!/bin/bash | |
set -eux -o pipefail | |
apt update | |
apt install software-properties-common -y | |
add-apt-repository ppa:longsleep/golang-backports -y | |
apt update | |
apt install golang-go git make -y | |
- mode: system | |
script: | | |
#!/bin/bash | |
set -eux -o pipefail | |
apt update | |
apt install curl wget zsh -y | |
- mode: user | |
script: | | |
#!/bin/bash | |
set -eux -o pipefail | |
sudo chsh -s $(which zsh) $USER | |
- mode: user | |
script: | | |
#!/bin/zsh | |
set -eux -o pipefail | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --unattended" | |
- mode: user | |
script: | | |
#!/bin/bash | |
set -eux -o pipefail | |
sudo groupadd docker || echo "group docker already exists" | |
sudo usermod -aG docker $USER | |
hostResolver: | |
# hostResolver.hosts requires lima 0.8.3 or later. Names defined here will also | |
# resolve inside containers, and not just inside the VM itself. | |
hosts: | |
host.docker.internal: host.lima.internal | |
portForwards: | |
- guestSocket: "/var/run/docker.sock" | |
hostSocket: "{{.Dir}}/sock/docker.sock" | |
message: | | |
To run `docker` on the host (assumes docker-cli is installed), run the following commands: | |
------ | |
docker context create lima --docker "host=unix://{{.Dir}}/sock/docker.sock" | |
docker context use lima | |
docker run hello-world | |
------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nach der Installation in der lima shell:
sudo usermod -aG docker $USER
Danach lima neustarten und Spaß haben!