Skip to content

cmd/create: Mount whole host instead of its subsets - #827

Merged
debarshiray merged 1 commit into
containers:mainfrom
martymichal:cmd/create/mount-whole-host
Jul 9, 2021
Merged

debarshiray merged 1 commit into
containers:mainfrom
martymichal:cmd/create/mount-whole-host

Conversation

@martymichal

Copy link
Copy Markdown
Member

Having whole host filesystem mounted inside of a toolbox is a very handy
feature that makes the toolboxes much more complete environment and
covers systems with diverse root directories (e.g., Fedora Silverblue).

Thanks to the chnge we can drop several separate mounts which are being
handled now by mounting the whole host filesystem.

@martymichal martymichal added 3. Enhancement Improvement to an existing feature 6. Major Change May cause breakage 2. Container Configuration Configuration of a container. Mounts, environmental variables, privileges. 6. Requires Toolbx Recreation This will take effect in new Toolbox containers and not in existing ones labels Jul 3, 2021
martymichal added a commit to martymichal/toolbox that referenced this pull request Jul 3, 2021
Having whole host filesystem mounted inside of a toolbox is a very handy
feature that makes the toolboxes much more complete environment and
covers systems with diverse root directories (e.g., Fedora Silverblue).

Thanks to the chnge we can drop several separate mounts which are being
handled now by mounting the whole host filesystem.

containers#827
@martymichal
martymichal force-pushed the cmd/create/mount-whole-host branch from d8aeeef to 4172be3 Compare July 3, 2021 18:47
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal martymichal added this to the Release 0.1.0 milestone Jul 3, 2021
debarshiray pushed a commit to martymichal/toolbox that referenced this pull request Jul 7, 2021
Having whole host filesystem mounted inside of a toolbox is a very handy
feature that makes the toolboxes much more complete environment and
covers systems with diverse root directories (e.g., Fedora Silverblue).

Thanks to the chnge we can drop several separate mounts which are being
handled now by mounting the whole host filesystem.

containers#827
@debarshiray
debarshiray force-pushed the cmd/create/mount-whole-host branch from 4172be3 to e7c9558 Compare July 7, 2021 18:30
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

debarshiray pushed a commit to martymichal/toolbox that referenced this pull request Jul 9, 2021
Having whole host filesystem mounted inside of a toolbox is a very handy
feature that makes the toolboxes much more complete environment and
covers systems with diverse root directories (e.g., Fedora Silverblue).

Thanks to the chnge we can drop several separate mounts which are being
handled now by mounting the whole host filesystem.

containers#827
@debarshiray
debarshiray force-pushed the cmd/create/mount-whole-host branch from e7c9558 to b8657f3 Compare July 9, 2021 13:48
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

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.

containers#827
@debarshiray
debarshiray force-pushed the cmd/create/mount-whole-host branch from b8657f3 to d03a5fe Compare July 9, 2021 15:52
@debarshiray
debarshiray merged commit d03a5fe into containers:main Jul 9, 2021

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, @HarryMichal

I merged it after tweaking the commit message to emphasize why the more complete environment is useful.

Comment thread src/cmd/create.go
homeDirMountArg := homeDirEvaled + ":" + homeDirEvaled + ":rslave"

bootMountFlags := "ro"
isBootReadWrite, err := isPathReadWrite("/boot")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there are host operating systems out there where we will have to check the read/write status of /?

I guess it's good to keep it simple unless we know for sure. :)

@martymichal
martymichal deleted the cmd/create/mount-whole-host branch July 9, 2021 16:34
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Oct 25, 2021
The path of the dynamic linker (ie., PT_INTERP), as specified in an
architecture's ABI, often starts with /lib or /lib64, not /usr/lib or
/usr/lib64. eg., it's /lib/ld-linux-aarch64.so.1 for aarch64 and
/lib64/ld-linux-x86-64.so.2 for x86_64.

Unfortunately, until very recently [1], only the host's /usr was
present inside a toolbox container's /run/host, not /lib or /lib64.
Therefore, simply prepending /run/host to the /usr/bin/toolbox
binary's existing PT_INTERP entry wouldn't locate the host's dynamic
linker inside the toolbox container. This broke backwards compatibility
with every container out there, except the ones created with the
current development version in Git.

To restore backwards compatibility, the /lib and /lib64 symbolic links
must be resolved to their respective locations inside /usr.

The following caveats must be noted:

  * With glibc, even the basename of the path of the dynamic linker as
    specified in an architecture's ABI, is a symbolic link to a file
    named ld-<glibc-version>.so. However, this file can't be used as
    the PT_INTERP entry, because its name will change when glibc is
    updated and the PT_INTERP entry will become invalid until the
    /usr/bin/toolbox binary is rebuilt.

  * On Debian, a path like /lib64/ld-linux-x86-64.so.2 doesn't resolve
    to something inside /usr/lib64. Instead it ends up inside
    /usr/lib/x86_64-linux-gnu through a series of symbolic links:
      - /lib64 -> usr/lib64
      - /usr/lib64/ld-linux-x86-64.so.2
          -> /lib/x86_64-linux-gnu/ld-2.28.so
      - /lib -> usr/lib

  * It's assumed that a symbolic link with the basename specified in
    the ABI lives in the same directory as the actual dynamic linker
    binary named ld-<glibc-version>.so.

Fallout from 6063eb2

[1] Commit d03a5fe
    containers#827

containers#821
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Oct 25, 2021
The path of the dynamic linker (ie., PT_INTERP), as specified in an
architecture's ABI, often starts with /lib or /lib64, not /usr/lib or
/usr/lib64. eg., it's /lib/ld-linux-aarch64.so.1 for aarch64 and
/lib64/ld-linux-x86-64.so.2 for x86_64.

Unfortunately, until very recently [1], only the host's /usr was
present inside a toolbox container's /run/host, not /lib or /lib64.
Therefore, simply prepending /run/host to the /usr/bin/toolbox
binary's existing PT_INTERP entry wouldn't locate the host's dynamic
linker inside the toolbox container. This broke backwards compatibility
with every container out there, except the ones created with the
current development version in Git.

To restore backwards compatibility, the /lib and /lib64 symbolic links
must be resolved to their respective locations inside /usr.

The following caveats must be noted:

  * With glibc, even the basename of the path of the dynamic linker as
    specified in an architecture's ABI, is a symbolic link to a file
    named ld-<glibc-version>.so. However, this file can't be used as
    the PT_INTERP entry, because its name will change when glibc is
    updated and the PT_INTERP entry will become invalid until the
    /usr/bin/toolbox binary is rebuilt.

  * On Debian, a path like /lib64/ld-linux-x86-64.so.2 doesn't resolve
    to something inside /usr/lib64. Instead it ends up inside
    /usr/lib/x86_64-linux-gnu through a series of symbolic links:
      - /lib64 -> usr/lib64
      - /usr/lib64/ld-linux-x86-64.so.2
          -> /lib/x86_64-linux-gnu/ld-2.28.so
      - /lib -> usr/lib

  * It's assumed that a symbolic link with the basename specified in
    the ABI lives in the same directory as the actual dynamic linker
    binary named ld-<glibc-version>.so.

Fallout from 6063eb2

[1] Commit d03a5fe
    containers#827

containers#821
debarshiray added a commit to containers/containertoolbx.org that referenced this pull request Jul 28, 2025
The ability to access the host file system from inside the container at
/run/host is an important feature that lets users add their own custom
bind mounts and symbolic links.  It emphasizes that Toolbx makes no
promise about security beyond what's already available in the usual
command line environment on the host.

Therefore, it's good to mention it prominently outside the manual page
for the 'create' command [1].

See:
containers/toolbox@d03a5fee80f2f72d
containers/toolbox#827

[1] https://github.com/containers/toolbox/blob/main/doc/toolbox-create.1.md

containers/toolbox#1649
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Feb 27, 2026
... similar to the website:
  https://containertoolbx.org/
  https://containertoolbx.org/doc/

The ability to access the host file system from inside the container at
/run/host is an important feature that lets users add their own custom
bind mounts and symbolic links [1].  It emphasizes that Toolbx makes no
promise about security beyond what's already available in the usual
command line environment on the host.

Until now, access to the host file system at /run/host was only
mentioned in the toolbox-create(1) manual [2].  Given its importance, it
should be mentioned as part of the top-level introductory text.

[1] Commit d03a5fe
    containers@d03a5fee80f2f72d
    containers#827

[2] Commit ea452d7
    containers@ea452d7ced8e798a
    containers#512

containers#1649
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Feb 27, 2026
... similar to the website:
  https://containertoolbx.org/
  https://containertoolbx.org/doc/

The ability to access the host file system from inside the container at
/run/host is an important feature that lets users add their own custom
bind mounts and symbolic links [1].  It emphasizes that Toolbx makes no
promise about security beyond what's already available in the usual
command line environment on the host.

Until now, access to the host file system at /run/host was only
mentioned in the toolbox-create(1) manual [2].  Given its importance, it
should be mentioned as part of the top-level introductory text.

[1] Commit d03a5fe
    containers@d03a5fee80f2f72d
    containers#827

[2] Commit ea452d7
    containers@ea452d7ced8e798a
    containers#512

containers#1649
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Mar 1, 2026
... similar to the website:
  https://containertoolbx.org/
  https://containertoolbx.org/doc/

The ability to access the host file system from inside the container at
/run/host is an important feature that lets users add their own custom
bind mounts and symbolic links [1].  It emphasizes that Toolbx makes no
promise about security beyond what's already available in the usual
command line environment on the host.

Until now, access to the host file system at /run/host was only
mentioned in the toolbox-create(1) manual [2].  Given its importance, it
should be mentioned as part of the top-level introductory text.

[1] Commit d03a5fe
    containers@d03a5fee80f2f72d
    containers#827

[2] Commit ea452d7
    containers@ea452d7ced8e798a
    containers#512

containers#1649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. Container Configuration Configuration of a container. Mounts, environmental variables, privileges. 3. Enhancement Improvement to an existing feature 6. Major Change May cause breakage 6. Requires Toolbx Recreation This will take effect in new Toolbox containers and not in existing ones

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants