lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.32k stars 602 forks source link

Unable to connect host after restart instance #2122

Open kamilos-dev opened 10 months ago

kamilos-dev commented 10 months ago

Description

Environment: MacBook ARM - M1

Steps to reproduce:

# Review and modify the following configuration for Lima instance "default2".
# - To cancel starting Lima, just save this file as an empty file.
(...)

arch: "x86_64"

# This template 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-20231211/ubuntu-22.04-server-cloudimg-amd64.img"
    arch: "x86_64"
    digest: "sha256:6d6af17f28c895d87e29092725370387c5e19efe57e58b96dc574feed4245f89"
  - location: "https://cloud-images.ubuntu.com/releases/22.04/release-20231211/ubuntu-22.04-server-cloudimg-arm64.img"
    arch: "aarch64"
    digest: "sha256:f885a8e8f62ab2c39ab0442ea182b69d49ccd990d24791acb4f1724573d8120f"
  # 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"
(...)

Somehow after lima instance restart I cannot connect to docker container again. Right now I need to remove lima instance and set up everything from scratch to make it works - but it is just workaround.

AkihiroSuda commented 10 months ago

Can you still enter into the instance with limactl shell?

afbjorklund commented 10 months ago

Don't you need to use --restart, for Docker to start the container again after a reboot ?

https://docs.docker.com/config/containers/start-containers-automatically/

kamilos-dev commented 10 months ago

Yes, I can enter into shell. Yes, docker info works.

This is output for lima-guestagent:

Do not launch manually

Usage:
  lima-guestagent [command]

Available Commands:
  completion      Generate the autocompletion script for the specified shell
  daemon          run the daemon
  help            Help about any command
  install-systemd install a systemd unit (user)

Flags:
      --debug     debug mode
  -h, --help      help for lima-guestagent
  -v, --version   version for lima-guestagent

Use "lima-guestagent [command] --help" for more information about a command.
kamilos-dev commented 10 months ago

@afbjorklund After stop lima instance all containers are also stopped. After start lima instance all containers are stopped and I started them by docker start $(docker ps -a -q)

kamilos-dev commented 10 months ago

I noticed right now that problem occurred only for instance named default. When I created an instance named default-problem and enter there by limactl shell default-problem I can stop/start this lima instance, docker containers works fine and curl -Ss "http://127.0.0.1:8044" -o /dev/null && echo ok returns ok from host all the time.

So the problem is only for default instance.

afbjorklund commented 10 months ago

Is this "default-problem" also running in emulation, or is that a native instance (arch: aarch64) ?

kamilos-dev commented 10 months ago

@AkihiroSuda @afbjorklund It turns out that the problem also occurs for names other than default.

When I created a docker container:

docker run \
    -d \
    -p 3050:3050 \
    -e FIREBIRD_DATABASE=db.fdb \
    -e FIREBIRD_USER=user \
    -e FIREBIRD_PASSWORD=Pass123 \
    -e ISC_PASSWORD=Pass123 \
    -v db-volume:/firebird \
    --name fbd \
    jacobalberty/firebird:3.0

and stop lima instance and start then I can't connect to either the firebird database or the nginx. From host curl -Ss "http://127.0.0.1:8044" -o /dev/null && echo ok returns curl: (7) Failed to connect to 127.0.0.1 port 8044 after 3 ms: Couldn't connect to server again.

Maybe there is some with firebird default pot 3050?