colima icon indicating copy to clipboard operation
colima copied to clipboard

DNS is not configured during provisioning

Open bas-de-laine opened this issue 2 months ago • 5 comments

Description

Since v0.9.0, when running provisioning scripts (from the templates provisioning section), DNS is not configured/working. At this point in time, there is no /etc/resolv.conf file.

Once the VM is booted, /etc/resolv.conf is materialized. Maybe setupDNS (https://github.com/abiosoft/colima/blob/main/environment/vm/lima/dns.go#L26) is called too late?

Version

colima version 0.9.1 git commit: 0cbf719f5409ce04b9f0607b681c005d2ff7d94a

runtime: docker arch: x86_64 client: v28.5.0 server: v28.4.0 limactl version 1.2.1 qemu-img version 10.1.0 Copyright (c) 2003-2025 Fabrice Bellard and the QEMU Project developers

Operating System

  • [ ] macOS Intel <= 13 (Ventura)
  • [x] macOS Intel >= 14 (Sonoma)
  • [ ] Apple Silicon <= 13 (Ventura)
  • [ ] Apple Silicon >= 14 (Sonoma)
  • [ ] Linux

Output of colima status

INFO[0000] colima is running using macOS Virtualization.Framework INFO[0000] arch: x86_64 INFO[0000] runtime: docker INFO[0000] mountType: virtiofs INFO[0000] docker socket: unix:///Users/bas-de-laine/.colima/default/docker.sock INFO[0000] containerd socket: unix:///Users/bas-de-laine/.colima/default/containerd.sock

Reproduction Steps

  1. Using the default template https://github.com/abiosoft/colima/blob/v0.9.1/embedded/defaults/colima.yaml, add a provisioning step to check whether /etc/resolv.conf exists and whether it is possible to resolve github.com:
provision:
  - mode: system
    script: |
      #!/usr/bin/env bash
      { 
        printf "Checking whether /etc/resolv.conf exists\n\n"
        [ -f /etc/resolv.conf ] && printf "🟢 /etc/resolv.conf exists\n" || printf "🔴 /etc/resolv.conf is missing\n" 
        printf "\nCalling getent ahosts github.com\n\n"
        getent ahosts github.com
      } > /Users/bas-de-laine/colima_resolv_conf_is_present.txt
  1. put the template in ~/.colima/_templates/default.yaml
  2. create the vm COLIMA_PROFILE=default colima start --template

Expected behaviour

I expect DNS to work when provisioning scripts run.

Additional context

No response

bas-de-laine avatar Oct 05 '25 19:10 bas-de-laine