Set machine docker.sock according to rootful flag

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:
Jason T. Greene
2023-05-12 13:35:49 -05:00
parent 2783651005
commit 5a176f09c2
12 changed files with 265 additions and 50 deletions

28
pkg/machine/update.go Normal file
View File

@ -0,0 +1,28 @@
//go:build amd64 || arm64
// +build amd64 arm64
package machine
import (
"fmt"
"github.com/sirupsen/logrus"
)
func UpdatePodmanDockerSockService(vm VM, name string, uid int, rootful bool) error {
content := GetPodmanDockerTmpConfig(uid, rootful, false)
command := fmt.Sprintf("'echo %q > %s'", content, PodmanDockerTmpConfPath)
args := []string{"sudo", "bash", "-c", command}
if err := vm.SSH(name, SSHOptions{Args: args}); err != nil {
logrus.Warnf("Could not not update internal docker sock config")
return err
}
args = []string{"sudo", "systemd-tmpfiles", "--create", "--prefix=/run/docker.sock"}
if err := vm.SSH(name, SSHOptions{Args: args}); err != nil {
logrus.Warnf("Could not create internal docker sock")
return err
}
return nil
}