Skip to content

Commit

Permalink
Look for cri-dockerd instead of hardcoding
Browse files Browse the repository at this point in the history
Some people install the daemon in /usr/local/bin,
rather than under /usr/bin as the unit expects.
  • Loading branch information
afbjorklund committed Feb 5, 2023
1 parent bd235db commit 90bc8a9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,14 @@ const (
CNICacheDir = "/var/lib/cni/cache"
)

func getCriDockerdPath(cr CommandRunner) string {
rr, err := cr.RunCmd(exec.Command("which", "cri-dockerd"))
if err != nil {
return "/usr/bin/cri-dockerd"
}
return strings.TrimSuffix(rr.Stdout.String(), "\n")
}

func dockerConfigureNetworkPlugin(cr CommandRunner, networkPlugin string) error {
// $ cri-dockerd --version
// cri-dockerd 0.2.6 (d8accf7)
Expand All @@ -702,17 +710,19 @@ func dockerConfigureNetworkPlugin(cr CommandRunner, networkPlugin string) error
networkPlugin = "cni"
}
opts := struct {
ExecPath string
NetworkPlugin string
ExtraArguments string
}{
ExecPath: getCriDockerdPath(cr),
NetworkPlugin: networkPlugin,
ExtraArguments: args,
}

const CRIDockerServiceConfFile = "/etc/systemd/system/cri-docker.service.d/10-cni.conf"
var CRIDockerServiceConfTemplate = template.Must(template.New("criDockerServiceConfTemplate").Parse(`[Service]
ExecStart=
ExecStart=/usr/bin/cri-dockerd --container-runtime-endpoint fd:// --network-plugin={{.NetworkPlugin}}{{.ExtraArguments}}`))
ExecStart={{.ExecPath}} --container-runtime-endpoint fd:// --network-plugin={{.NetworkPlugin}}{{.ExtraArguments}}`))

b := bytes.Buffer{}
if err := CRIDockerServiceConfTemplate.Execute(&b, opts); err != nil {
Expand Down

0 comments on commit 90bc8a9

Please sign in to comment.