abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
19.52k stars 396 forks source link

Short form entry from /etc/hosts is not resolved #895

Open slobodator opened 12 months ago

slobodator commented 12 months ago

Description

Short form entries from the host /etc/hosts were resolvable but I upgraded the version (don't remember what I had before) and the resolving broke.

Version

colima version 0.6.2 git commit: 22d7e5fbc86d5b8e3b27065a762800bc7960a0ff limactl version 0.18.0 qemu-img version 8.1.2

Operating System

Output of colima status

INFO[0000] colima [profile=m1] is running using macOS Virtualization.Framework INFO[0000] arch: aarch64 INFO[0000] runtime: docker INFO[0000] mountType: virtiofs INFO[0000] socket: unix:///Users/andriy.slobodyanyk/.colima/m1/docker.sock

Reproduction Steps

I have 192.168.5.2 at the host /etc/hosts file.

❯ grep oracle /etc/hosts
192.168.5.2 oracle

and

network:
  address: false
  dns: []
  dnsHosts:
    example.com: 1.2.3.4
    oracle: 192.168.5.2

at the .colima/m1/colima.yaml

I would like to resolve the oracle name within the container.

It works if there is no internal network docker run -it --rm arm64v8/alpine getent hosts example.com oracle

1.2.3.4           example.com  example.com
192.168.5.2       oracle  oracle

also I noticed that docker run -it --rm arm64v8/alpine cat /etc/resolv.conf

nameserver 192.168.5.2

However, if there is some internal network (I have one because this setup is used not only locally) docker network create some_network

the behaviour is different. oracle is not resolved anymore. docker run -it --rm --network some_network arm64v8/alpine getent hosts example.com oracle

1.2.3.4           example.com  example.com

Still, any FQDN with dots from the /etc/hosts like a.b.com is resolved well.

The nameserver is also different docker run -it --rm --network some_network arm64v8/alpine cat /etc/resolv.conf

nameserver 127.0.0.11
options edns0 trust-ad ndots:0

Expected behaviour

It would be really nice to have a possibility to resolve oracle again i.e. docker run -it --rm --network some_network arm64v8/alpine getent hosts oracle

For the moment the only workaround I have is to add

    extra_hosts:
      - oracle:192.168.5.2

to the docker-compose and not to commit the change.

Additional context

No response

slobodator commented 12 months ago

Luckily that old working version remained at my private laptop

❯ docker run -it --rm --network some_network arm64v8/alpine getent hosts oracle
192.168.5.2       oracle  oracle

The entry is resolved by the host machine /etc/hosts file, there are no dnsHosts at the colima.yaml.

❯ docker run -it --rm --network some_network arm64v8/alpine cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0
❯ colima version && limactl --version && qemu-img --version
colima version HEAD-627c4fd
git commit: 627c4fdbba9c6c35932625b15ce723a084fd402a

runtime: docker
arch: aarch64
client: v20.10.17
server: v23.0.6
limactl version 0.18.0
qemu-img version 8.1.2

MacOS is also Sonoma 14.0 at M1

slobodator commented 12 months ago

So, made a binary search :-) to detect the issue. It worked latest at 0.5.6, stopped working at 0.6.0. I seem to have to downgrade as described as brew install colima@0.5.6 also doesn't work to me.

abiosoft commented 12 months ago

Thanks for reporting.

jdmarshall commented 11 months ago

Do you have an addon for that? brew install colima@version just results in confusion from mine

slobodator commented 11 months ago

@jdmarshall brew installs just the latest version of colima, if you need other one you seem to have to install it manually

jdmarshall commented 11 months ago

@slobodator Yeah I went through that yesterday.

That is not something I ever want to have to explain to another human.