Skip to content

Commit d03a5fe

Browse files
martymichaldebarshiray
authored andcommitted
cmd/create: Expose the host's entire / in the container at /run/host
Having the entire host file system hierarchy mounted inside a toolbox container gives the containers a more complete environment that's resilient against future changes in the layout of the file system hierarchy and the need for giving access to new paths to support new use-cases. Otherwise, one would have to create a new container to get access to any path that lies outside the /boot, /etc, /run, /tmp, /usr and /var directories. As a nice side-effect, this also simplifies the bind mount handling code. #827
1 parent 94917b7 commit d03a5fe

1 file changed

Lines changed: 1 addition & 28 deletions

File tree

‎src/cmd/create.go‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -265,28 +265,6 @@ func createContainer(container, image, release string, showCommandToEnter bool)
265265
logrus.Debugf("%s canonicalized to %s", currentUser.HomeDir, homeDirEvaled)
266266
homeDirMountArg := homeDirEvaled + ":" + homeDirEvaled + ":rslave"
267267

268-
bootMountFlags := "ro"
269-
isBootReadWrite, err := isPathReadWrite("/boot")
270-
if err != nil {
271-
return err
272-
}
273-
if isBootReadWrite {
274-
bootMountFlags = "rw"
275-
}
276-
277-
bootMountArg := "/boot:/run/host/boot:" + bootMountFlags + ",rslave"
278-
279-
usrMountFlags := "ro"
280-
isUsrReadWrite, err := isPathReadWrite("/usr")
281-
if err != nil {
282-
return err
283-
}
284-
if isUsrReadWrite {
285-
usrMountFlags = "rw"
286-
}
287-
288-
usrMountArg := "/usr:/run/host/usr:" + usrMountFlags + ",rslave"
289-
290268
var avahiSocketMount []string
291269

292270
avahiSocket, err := getServiceSocket("Avahi", "avahi-daemon.socket")
@@ -423,16 +401,11 @@ func createContainer(container, image, release string, showCommandToEnter bool)
423401
createArgs = append(createArgs, []string{
424402
"--userns", usernsArg,
425403
"--user", "root:root",
426-
"--volume", "/etc:/run/host/etc",
404+
"--volume", "/:/run/host:rslave",
427405
"--volume", "/dev:/dev:rslave",
428-
"--volume", "/run:/run/host/run:rslave",
429-
"--volume", "/tmp:/run/host/tmp:rslave",
430-
"--volume", "/var:/run/host/var:rslave",
431-
"--volume", bootMountArg,
432406
"--volume", dbusSystemSocketMountArg,
433407
"--volume", homeDirMountArg,
434408
"--volume", toolboxPathMountArg,
435-
"--volume", usrMountArg,
436409
"--volume", runtimeDirectoryMountArg,
437410
}...)
438411

0 commit comments

Comments
 (0)