Draft and Incomplete. Help us authoring by clicking the github icon nearby.
Unshare
The Podman container technology relies on namespaces. New Linux Namespaces are typically spawned by using either the clone or unshare system calls. These exist as C functions that have wrapper in many languages.
For using in a shell, unshare is more straight forward.
When you run unshare in a shell, it does not directly executue but wraps the real unshare kernel call inside of itself.
The mnt_ns is what responsible for storing the mount table in Linux kernel. When a sandboxed environment like a container runs in a new Mount Namespace, it can mount filesystems not present on the host.
depending on where you are using, you may need sudo.
- Unshare wraps the unshare kernel sys call.
-mrequests a mount new Namespace./bin/bashtells what program to run after the mount. We ran bash thus, it gave a bash terminal
It creates a tem fs in ram and covers up the existing up one.
Now lets add something to the new /mnt
Seems date added to /mnt ?
We can exit the name space either by closing the terminal tab or using the exit command.
Now let's try reading from /mnt/date
As it was created in a temporary mount namespace, it is gone after exit.