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

containerd: add socket forwarding to host #1017

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions environment/container/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ package containerd
import (
"context"
_ "embed"
"path/filepath"
"time"

"github.com/abiosoft/colima/cli"
"github.com/abiosoft/colima/config"
"github.com/abiosoft/colima/environment"
)

// Name is container runtime name
const Name = "containerd"

func HostSocketFile() string { return filepath.Join(config.Dir(), "containerd.sock") }
DieterBuys marked this conversation as resolved.
Show resolved Hide resolved

// This is written with assumption that Lima is the VM,
// which provides nerdctl/containerd support out of the box.
// There may be need to make this flexible for non-Lima VMs.
Expand Down
11 changes: 11 additions & 0 deletions environment/vm/lima/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/abiosoft/colima/config"
"github.com/abiosoft/colima/environment"
"github.com/abiosoft/colima/environment/container/containerd"
"github.com/abiosoft/colima/environment/container/docker"
"github.com/abiosoft/colima/util"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -198,6 +199,16 @@ func newConf(ctx context.Context, conf config.Config) (l Config, err error) {
}
}

// containerd socket
if conf.Runtime == containerd.Name {
l.PortForwards = append(l.PortForwards,
PortForward{
GuestSocket: "/var/run/containerd.sock",
HostSocket: containerd.HostSocketFile(),
Proto: TCP,
})
}

// handle port forwarding to allow listening on 0.0.0.0
// bind 0.0.0.0
l.PortForwards = append(l.PortForwards,
Expand Down