Skip to content

Commit

Permalink
Only use DOCKER_RAMDISK on fstype rootfs
Browse files Browse the repository at this point in the history
The docker configuration is determined at runtime,
so make it work with both old rootfs and new tmpfs.
  • Loading branch information
afbjorklund committed Aug 19, 2019
1 parent 8c2dc5b commit 17dd510
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/provision/buildroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ func (p *BuildrootProvisioner) GenerateDockerOptions(dockerPort int) (*provision
driverNameLabel := fmt.Sprintf("provider=%s", p.Driver.DriverName())
p.EngineOptions.Labels = append(p.EngineOptions.Labels, driverNameLabel)

noPivot := true
// Using pivot_root is not supported on fstype rootfs
if fstype, err := rootFileSystemType(p); err == nil {
log.Debugf("root file system type: %s", fstype)
noPivot = fstype == "rootfs"
}

engineConfigTmpl := `[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
Expand All @@ -96,8 +103,14 @@ Requires= minikube-automount.service docker.socket
[Service]
Type=notify
`
if noPivot {
engineConfigTmpl += `
# DOCKER_RAMDISK disables pivot_root in Docker, using MS_MOVE instead.
Environment=DOCKER_RAMDISK=yes
`
}
engineConfigTmpl += `
{{range .EngineOptions.Env}}Environment={{.}}
{{end}}
Expand Down Expand Up @@ -155,6 +168,14 @@ WantedBy=multi-user.target
}, nil
}

func rootFileSystemType(p *BuildrootProvisioner) (string, error) {
fs, err := p.SSHCommand("df --output=fstype / | sed 1d")
if err != nil {
return "", err
}
return strings.TrimSpace(fs), nil
}

// Package installs a package
func (p *BuildrootProvisioner) Package(name string, action pkgaction.PackageAction) error {
return nil
Expand Down

0 comments on commit 17dd510

Please sign in to comment.