Skip to content

Commit edea8f9

Browse files
committed
Only use DOCKER_RAMDISK on fstype rootfs
The docker configuration is determined at runtime, so make it work with both old rootfs and new tmpfs.
1 parent b89a9f6 commit edea8f9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: pkg/provision/buildroot.go

+21
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ func (p *BuildrootProvisioner) GenerateDockerOptions(dockerPort int) (*provision
9292
driverNameLabel := fmt.Sprintf("provider=%s", p.Driver.DriverName())
9393
p.EngineOptions.Labels = append(p.EngineOptions.Labels, driverNameLabel)
9494

95+
noPivot := true
96+
// Using pivot_root is not supported on fstype rootfs
97+
if fstype, err := rootFileSystemType(p); err == nil {
98+
log.Debugf("root file system type: %s", fstype)
99+
noPivot = fstype == "rootfs"
100+
}
101+
95102
engineConfigTmpl := `[Unit]
96103
Description=Docker Application Container Engine
97104
Documentation=https://docs.docker.com
@@ -101,8 +108,14 @@ Requires= minikube-automount.service docker.socket
101108
[Service]
102109
Type=notify
103110
111+
`
112+
if noPivot {
113+
engineConfigTmpl += `
104114
# DOCKER_RAMDISK disables pivot_root in Docker, using MS_MOVE instead.
105115
Environment=DOCKER_RAMDISK=yes
116+
`
117+
}
118+
engineConfigTmpl += `
106119
{{range .EngineOptions.Env}}Environment={{.}}
107120
{{end}}
108121
@@ -160,6 +173,14 @@ WantedBy=multi-user.target
160173
}, nil
161174
}
162175

176+
func rootFileSystemType(p *BuildrootProvisioner) (string, error) {
177+
fs, err := p.SSHCommand("df --output=fstype / | tail -n 1")
178+
if err != nil {
179+
return "", err
180+
}
181+
return strings.TrimSpace(fs), nil
182+
}
183+
163184
// Package installs a package
164185
func (p *BuildrootProvisioner) Package(name string, action pkgaction.PackageAction) error {
165186
return nil

0 commit comments

Comments
 (0)