Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/abiosoft/colima/environment"
"github.com/abiosoft/colima/environment/container/containerd"
"github.com/abiosoft/colima/environment/container/docker"
"github.com/abiosoft/colima/environment/container/incus"
"github.com/abiosoft/colima/environment/container/kubernetes"
"github.com/abiosoft/colima/environment/host"
"github.com/abiosoft/colima/environment/vm/lima"
Expand Down Expand Up @@ -300,10 +301,11 @@ type statusInfo struct {
Arch string `json:"arch"`
Runtime string `json:"runtime"`
MountType string `json:"mount_type"`
IPAddress string `json:"ip_address"`
DockerSocket string `json:"docker_socket"`
ContainerdSocket string `json:"containerd_socket"`
BuildkitdSocket string `json:"buildkitd_socket"`
IPAddress string `json:"ip_address,omitempty"`
DockerSocket string `json:"docker_socket,omitempty"`
ContainerdSocket string `json:"containerd_socket,omitempty"`
BuildkitdSocket string `json:"buildkitd_socket,omitempty"`
IncusSocket string `json:"incus_socket,omitempty"`
Kubernetes bool `json:"kubernetes"`
CPU int `json:"cpu"`
Memory int64 `json:"memory"`
Expand Down Expand Up @@ -336,11 +338,15 @@ func (c colimaApp) getStatus() (status statusInfo, err error) {
}
if currentRuntime == docker.Name {
status.DockerSocket = "unix://" + docker.HostSocketFile()
status.ContainerdSocket = "unix://" + containerd.HostSocketFiles().Containerd
}
if currentRuntime == containerd.Name {
status.ContainerdSocket = "unix://" + containerd.HostSocketFiles().Containerd
status.BuildkitdSocket = "unix://" + containerd.HostSocketFiles().Buildkitd
}
if currentRuntime == incus.Name {
status.IncusSocket = "unix://" + incus.HostSocketFile()
}
if k, err := c.Kubernetes(); err == nil && k.Running(ctx) {
status.Kubernetes = true
}
Expand Down Expand Up @@ -377,14 +383,17 @@ func (c colimaApp) Status(extended bool, jsonOutput bool) error {

// docker socket
if status.DockerSocket != "" {
log.Println("socket:", status.DockerSocket)
log.Println("docker socket:", status.DockerSocket)
}
if status.ContainerdSocket != "" {
log.Println("containerd socket:", status.ContainerdSocket)
}
if status.BuildkitdSocket != "" {
log.Println("buildkitd socket:", status.BuildkitdSocket)
}
if status.IncusSocket != "" {
log.Println("incus socket:", status.IncusSocket)
}

// kubernetes
if status.Kubernetes {
Expand Down
4 changes: 4 additions & 0 deletions environment/container/docker/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
disabled_plugins = ["cri"]

[grpc]
gid = 1000
44 changes: 44 additions & 0 deletions environment/container/docker/containerd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package docker

import (
"context"
_ "embed"
"fmt"
)

const containerdConfFile = "/etc/containerd/config.toml"
const containerdConfFileBackup = "/etc/containerd/config.colima.bak.toml"

//go:embed config.toml
var containerdConf []byte

func (d dockerRuntime) provisionContainerd(ctx context.Context) error {
a := d.Init(ctx)

// containerd config
a.Add(func() error {
if _, err := d.guest.Stat(containerdConfFileBackup); err == nil {
// backup already exists, no need to overwrite
return nil
}

// backup existing containerd config
if err := d.guest.Run("sudo", "cp", containerdConfFile, containerdConfFileBackup); err != nil {
return fmt.Errorf("error backing up %s: %w", containerdConfFile, err)
}

// write new containerd config
if err := d.guest.Write(containerdConfFile, containerdConf); err != nil {
return fmt.Errorf("error writing %s: %w", containerdConfFile, err)
}

return nil
})

a.Add(func() error {
// restart containerd service
return d.guest.Run("sudo", "service", "containerd", "restart")
})

return a.Exec()
}
5 changes: 4 additions & 1 deletion environment/container/docker/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func (d dockerRuntime) createDaemonFile(conf map[string]any, env map[string]stri

// enable buildkit (if not set by user)
if _, ok := conf["features"]; !ok {
conf["features"] = map[string]any{"buildkit": true}
conf["features"] = map[string]any{
"buildkit": true,
"containerd-snapshotter": true,
}
}

// enable cgroupfs for k3s (if not set by user)
Expand Down
5 changes: 5 additions & 0 deletions environment/container/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func (d dockerRuntime) Provision(ctx context.Context) error {

conf, _ := ctx.Value(config.CtxKey()).(config.Config)

// provision containerd
a.Add(func() error {
return d.provisionContainerd(ctx)
})

// daemon.json
a.Add(func() error {
// these are not fatal errors
Expand Down
6 changes: 6 additions & 0 deletions environment/vm/lima/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ func newConf(ctx context.Context, conf config.Config) (l limaconfig.Config, err
GuestSocket: "/var/run/docker.sock",
HostSocket: docker.HostSocketFile(),
Proto: limaconfig.TCP,
},
limaconfig.PortForward{
GuestSocket: "/var/run/containerd/containerd.sock",
HostSocket: containerd.HostSocketFiles().Containerd,
Proto: limaconfig.TCP,
})

if config.CurrentProfile().ShortName == "default" {
// for backward compatibility, will be removed in future releases
l.PortForwards = append(l.PortForwards,
Expand Down