https://rancher.com/ logo
#lima
Title
# lima
a

adamant-kite-43734

06/15/2022, 3:45 PM
This message was deleted.
g

great-rainbow-93322

06/16/2022, 8:18 AM
did you restart the Lima VM after its creation?
see also this trick that avoids a VM restart: https://github.com/lima-vm/lima/issues/455#issue-1072389920
c

clean-fireman-4784

06/16/2022, 1:59 PM
Was not aware that a restart was needed. But after a restart still not working. When I try to access the socket via curl, got the following:
Copy code
curl -XGET --unix-socket /Users/USER/.lima/docker_x86_64_root/sock/docker.sock <http://localhost/info>
curl: (52) Empty reply from server
With other vms it's working. When using
limactl shell docker_x86_64_root
then using the
sudo docker ps
is working without issues. Something not allowed on the guest?
Got it working, indeed it's important to reboot the vm. This is what I used:
Copy code
# 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 ...

arch: "x86_64"

# 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/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img>"
  arch: "x86_64"
- location: "<https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-arm64.img>"
  arch: "aarch64"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "<https://cloud-images.ubuntu.com/releases/21.10/release/ubuntu-21.10-server-cloudimg-amd64.img>"
  arch: "x86_64"
- location: "<https://cloud-images.ubuntu.com/releases/21.10/release/ubuntu-21.10-server-cloudimg-arm64.img>"
  arch: "aarch64"

mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
# 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> | sh
- mode: user
  script: |
    #!/bin/bash
    set -eux -o pipefail
    systemctl --user start dbus
    sudo usermod -G docker -a $(whoami)
probes:
- script: |
    #!/bin/bash
    set -eux -o pipefail
    if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
      echo >&2 "docker is not installed yet"
      exit 1
    fi
  hint: See "/var/log/cloud-init-output.log". in the guest
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
  ------
g

great-rainbow-93322

06/17/2022, 6:49 AM
if that can help, here is my lima config for docker: https://gist.github.com/bcollard/e75a67917b7b8797a3eeabcb476f9bf4 After VM creation, I restart it and then I run
Copy code
export DOCKER_HOST=unix://$HOME/docker.sock
8 Views