diff --git a/cmd/start.go b/cmd/start.go index 45231b66c..37f783300 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -170,8 +170,8 @@ func init() { startCmd.Flags().StringToStringVar(&startCmdArgs.Env, "env", nil, "environment variables for the VM") // dns - startCmd.Flags().IPSliceVarP(&startCmdArgs.Network.DNSResolvers, "dns", "n", nil, "DNSResolvers servers for the VM") - startCmd.Flags().StringSliceVarP(&startCmdArgs.Flags.DNSHosts, "dns-host", "", nil, "Custom DNS names to provide to resolver") + startCmd.Flags().IPSliceVarP(&startCmdArgs.Network.DNSResolvers, "dns", "n", nil, "DNS resolvers for the VM") + startCmd.Flags().StringSliceVar(&startCmdArgs.Flags.DNSHosts, "dns-host", nil, "Custom DNS names to provide to resolver") } func dnsHostsFromFlag(hosts []string) map[string]string { diff --git a/config/config.go b/config/config.go index 612c123a2..07cb6d512 100644 --- a/config/config.go +++ b/config/config.go @@ -117,7 +117,7 @@ type Kubernetes struct { type Network struct { Address bool `yaml:"address"` DNSResolvers []net.IP `yaml:"dns"` - DNSHosts map[string]string `yaml:"dns_hosts"` + DNSHosts map[string]string `yaml:"dnsHosts"` } // Mount is volume mount diff --git a/docs/FAQ.md b/docs/FAQ.md index f5c62cd11..f520d0417 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -27,6 +27,9 @@ - [Accessing the underlying Virtual Machine](#accessing-the-underlying-virtual-machine) - [The Virtual Machine's IP is not reachable](#the-virtual-machines-ip-is-not-reachable) - [Enable reachable IP address](#enable-reachable-ip-address) + - [How can disk space be recovered?](#how-can-disk-space-be-recovered) + - [Automatic](#automatic) + - [Manual](#manual) - [Are Lima overrides supported?](#are-lima-overrides-supported) ## How does Colima compare to Lima? @@ -107,7 +110,7 @@ docker context use ``` ### Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? -Colima uses Docker contexts to allow co-existence with other Docker servers and sets itself as the default Docker context on startup. +Colima uses Docker contexts to allow co-existence with other Docker servers and sets itself as the default Docker context on startup. However, some applications are not aware of Docker contexts and may lead to the error. @@ -120,7 +123,7 @@ This can be fixed by any of the following approaches. Ensure the Docker socket p ```sh export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock" ``` -3. Linking the Colima socket to the default socket path. **Note** that this may break other Docker servers. +3. Linking the Colima socket to the default socket path. **Note** that this may break other Docker servers. ```sh sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock @@ -133,24 +136,24 @@ This can be fixed by any of the following approaches. Ensure the Docker socket p On first startup, Colima generates Docker daemon.json file at `$HOME/.colima/docker/daemon.json`. Modify the daemon.json file accordingly and restart Colima. - + * v0.4.0 or newer Start Colima with `--edit` flag. - + ```sh colima start --edit ``` - + Add the Docker config to the `docker` section. - + ```diff - docker: {} + docker: + insecure-registries: + - myregistry.com:5000 + - host.docker.internal:5000 - ``` + ``` ### Docker plugins are missing (buildx, scan) @@ -236,7 +239,7 @@ The underlying Virtual Machine is still accessible by specifying `--layer=false` ## The Virtual Machine's IP is not reachable -This is by design. Reachable IP address is not enabled by default because it requires root access. +Reachable IP address is not enabled by default due to slower startup time. ### Enable reachable IP address @@ -253,6 +256,24 @@ This is by design. Reachable IP address is not enabled by default because it req + address: true ``` +## How can disk space be recovered? + +Disk space can be freed in the VM by removing containers or running `docker system prune`. +However, it will not reflect on the host on Colima versions v0.4.x or lower. + +### Automatic + +For Colima v0.5.0 and above, unused disk space in the VM is released on startup. A restart would suffice. + +### Manual + +For Colima v0.5.0 and above, user can manually recover the disk space by running `sudo fstrim -a` in the VM. + +```sh +# '-v' may be added for verbose output +colima ssh -- sudo fstrim -a +``` + ## Are Lima overrides supported? Yes, however this should only be done by advanced users. diff --git a/docs/INSTALL.md b/docs/INSTALL.md index c354423b8..1565e2d81 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -42,7 +42,7 @@ Binaries are available with every release on the [releases page](https://github. ```sh # download binary -curl -LO https://github.com/abiosoft/colima/releases/download/v0.4.0/colima-$(uname)-$(uname -m) +curl -LO https://github.com/abiosoft/colima/releases/download/v0.5.0/colima-$(uname)-$(uname -m) # install in $PATH install colima-$(uname)-$(uname -m) /usr/local/bin/colima # or sudo install if /usr/local/bin requires root. diff --git a/embedded/defaults/colima.yaml b/embedded/defaults/colima.yaml index 5739d48dd..e4eef9577 100644 --- a/embedded/defaults/colima.yaml +++ b/embedded/defaults/colima.yaml @@ -64,7 +64,12 @@ network: # DNS hostnames to resolve to custom targets using the internal Lima resolver. # This setting has no effect if a custom DNS resolver list is supplied above. # It does not configure the /etc/hosts files of any machine or container. - dns_hosts: + # The value can be an IP address or another host. + # + # EXAMPLE + # dnsHosts: + # example.com: 1.2.3.4 + dnsHosts: host.docker.internal: host.lima.internal # ===================================================================== # @@ -130,12 +135,12 @@ layer: false # Custom provision scripts for the virtual machine. # Provisioning scripts are executed on startup and therefore needs to be idempotent. # -# Example - script exected as root +# EXAMPLE - script exected as root # provision: # - mode: system # script: apk add htop vim # -# Example - script exected as user +# EXAMPLE - script exected as user # provision: # - mode: user # script: | @@ -174,4 +179,4 @@ mounts: [] # ANOTHER_KEY: another value # # Default: {} -env: {} \ No newline at end of file +env: {} diff --git a/environment/container/kubernetes/containerd.go b/environment/container/kubernetes/cni.go similarity index 88% rename from environment/container/kubernetes/containerd.go rename to environment/container/kubernetes/cni.go index 26ed6727c..4af2eb06e 100644 --- a/environment/container/kubernetes/containerd.go +++ b/environment/container/kubernetes/cni.go @@ -10,7 +10,7 @@ import ( "github.com/abiosoft/colima/environment" ) -func installContainerdDeps(guest environment.GuestActions, a *cli.ActiveCommandChain) { +func installCniConfig(guest environment.GuestActions, a *cli.ActiveCommandChain) { // fix cni config a.Add(func() error { flannelFile := "/etc/cni/net.d/10-flannel.conflist" diff --git a/environment/container/kubernetes/kubernetes.go b/environment/container/kubernetes/kubernetes.go index 7f4cf2e7f..cedccd374 100644 --- a/environment/container/kubernetes/kubernetes.go +++ b/environment/container/kubernetes/kubernetes.go @@ -126,13 +126,15 @@ func (c *kubernetesRuntime) Provision(ctx context.Context) error { } // this needs to happen on each startup - switch runtime { - case containerd.Name: - installContainerdDeps(c.guest, a) - case docker.Name: - a.Retry("waiting for docker cri", time.Second*2, 5, func(int) error { - return c.guest.Run("sudo", "service", "cri-dockerd", "start") - }) + { + // cni is used by both cri-dockerd and containerd + installCniConfig(c.guest, a) + + if runtime == docker.Name { + a.Retry("waiting for docker cri", time.Second*2, 5, func(int) error { + return c.guest.Run("sudo", "service", "cri-dockerd", "start") + }) + } } // provision successful, now we can persist the version