Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colima ignores template's DNS config #1219

Open
1 of 5 tasks
gereog opened this issue Dec 16, 2024 · 11 comments
Open
1 of 5 tasks

colima ignores template's DNS config #1219

gereog opened this issue Dec 16, 2024 · 11 comments

Comments

@gereog
Copy link

gereog commented Dec 16, 2024

Description

I was getting these errors when trying to start a docker container:

failed to solve: redis:7: failed to resolve source metadata for docker.io/library/redis:7: failed to do request: Head "https://registry-1.docker.io/v2/library/redis/manifests/7": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: no such host

So I went into colima template, changed network.dns to 8.8.8.8, 8.8.4.4, then ran colima restart

# Network configurations for the virtual machine.
network:
  # Custom DNS resolvers for the virtual machine.
  #
  # EXAMPLE
  # dns: [8.8.8.8, 1.1.1.1]
  #
  # Default: []
  dns:
    - 8.8.8.8
    - 8.8.4.4
  

I've run colima restart, colima stop, colima start, etc.

Nothing worked, I got exactly the same error message every time

failed to solve: redis:7: failed to resolve source metadata for docker.io/library/redis:7: failed to do request: Head "https://registry-1.docker.io/v2/library/redis/manifests/7": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: no such host

Which was surprising, because 127.0.0.53 is not in my /etc/resolv.conf, it's not in my scutil --dns, and it's not in my colima template! (I double checked several times, colima template was not getting reset or anything)

However, when I ran

colima stop
colima start --dns=8.8.8.8,8.8.4.4

The issue finally resolved.

I guess this means that colima template's DNS configurations are being ignored. Only the command-line flag works.

Version

colima version 0.8.0
git commit: 9c08cff

runtime: docker
arch: aarch64
client: v27.3.1
server: v27.3.1
limactl version 1.0.1

Operating System

  • macOS Intel <= 13 (Ventura)
  • 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: aarch64
INFO[0000] runtime: docker
INFO[0000] mountType: sshfs
INFO[0000] socket: unix:///Users/me/.colima/default/docker.sock

Reproduction Steps

  1. Change dns values in colima template
  2. colima restart

Expected behaviour

docker will use the template-specified DNS servers

Additional context

No response

@dcitterio
Copy link

dcitterio commented Dec 19, 2024

Hey gereog,
I think you got confused about the purpose of colima template, or maybe it is not clear in the docs.

template edits the base configuration used only when you create a new VM, it will not change the current instance of Colima that you're running.
You could find the template file in ~/.colima/_templates/default.yaml.

So, if you create a new profile with colima start -P <profile-name> or delete and recreate the default instance , Colima will uses the template configuration.

To change the current instance of Colima you could either:

  • Update ~/.colima/default/colima.yaml file or,
  • Use the inline flags in colima start as you did

I hope it is a little more clear than before :)

@gereog
Copy link
Author

gereog commented Dec 19, 2024

@dcitterio Why doesn't colima stop, colima template, colima start create a new vm, using the template?

@dcitterio
Copy link

dcitterio commented Dec 20, 2024

You have to think that a "profile" is basically a VM that runs with its own configuration.

colima start runs the profile called default by default, and if the profile doesn't exist then it'll create it.
By using -P, you can choose to use another profile, which means that the profile will be created if it doesn't exist.

Every time you create a new profile, the VM will be created with the information that you configured in colima template.

If you run colima ls you can see every profile that you have.

colima stop simply stops the VM and nothing more

colima template allow you to customize ~/.colima/_templates/default.yaml file. It doesn't create or start anything

@gereog
Copy link
Author

gereog commented Dec 20, 2024

@dcitterio Thanks so much for the good explanation. Is the persistence of the default profile helpful to most people? Is there a way to make colima start delete and recreate the default profile every time?

@dcitterio
Copy link

dcitterio commented Dec 24, 2024

Is the persistence of the default profile helpful to most people?

Absolutely. The VM contains all the docker images that you downloaded of built.
For instance, if you need a Postgres DB for your local development, you don't want to download it from Docker Hub every time you start working with Docker.

Is there a way to make colima start delete and recreate the default profile every time?

Not directly. Still, I don't think that it is useful at all.
What do you want to achieve by recreating the profile every time?

@gereog
Copy link
Author

gereog commented Dec 24, 2024

Is there a way to make colima start delete and recreate the default profile every time?

Not directly. Still, I don't think that it is useful at all. What do you want to achieve by recreating the profile every time?

I want to make it so that changes to the template will actually change the VM's configuration...

I would like it so that updating memory limits, storage limits, and DNS nameservers in the template will actually change the memory and storage limits and DNS nameservers of the docker VM.

@dcitterio
Copy link

I would like it so that updating memory limits, storage limits, and DNS nameservers in the template will actually change the memory and storage limits and DNS nameservers of the docker VM.

Got it.
In this scenario you need to use start command with the flags for the parameters that you want to change (like you did for the DNS),
or you could directly edit ~/.colima/default/colima.yaml configuration file.

@gereog
Copy link
Author

gereog commented Dec 31, 2024

@dcitterio if I edit ~/.colima/default/colima.yaml directly

  1. will all the docker images that I've downloaded and built get deleted?
  2. Will the settings actually take effect next time I run colima start with no flags?

@dcitterio
Copy link

dcitterio commented Dec 31, 2024

will all the docker images that I've downloaded and built get deleted?

No, This happens only if you delete the VM with colima delete

Will the settings actually take effect next time I run colima start with no flags?

Correct. You can change almost everything.
There only a couple of parameters that you cannot change once the VM is created, like enabling Rosetta.
I don't recall the exact list to be honest, but I don't think you're going to bump into them ;)

@gereog
Copy link
Author

gereog commented Jan 7, 2025

Then, I don't understand why colima template wouldn't simply edit ~/.colima/default/colima.yaml, instead of opening an editor for changes that won't be applied until you delete your docker images.

@dcitterio
Copy link

template is a feature that is very useful if you want to run multiple instances at the same time. I'm using it usually when I want to create a k8s and run some destructive experiments.
template doesn't fit your use case for sure.

I also forgot that you can run colima start --edit which is exactly what you probably need.
I always edit the yml directly and I totally forgot of this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants