who)ps aux)path → file/directoryDependencies
root90s - bespoke, targeted development
00s - frameworks, and increased application complexity
10s - Applications via composition
Now - Assumed containers for distribution
A Name is often a string or integer used to uniquely identify or address a resource.
A Namespace is the set of these Names.
Name Examples:
What are UNIX namespaces? In Linux: read more in man namespaces.
pid_namespaces(7) - Process IDsuser_namespaces(7) - User IDs/Group IDsmount_namespaces(7) - Filesystem namespacesipc_namespaces(7) - System V IPC/POSIX message queue IDsnetwork_namespaces(7) - Networking identity and addressesuts_namespaces(7) - System identity (hostname)The unshare system call unshares namespaces in the next forked child.
pid ExampleContainers can have overlapping pids, and cannot address other container’s pids!
$ whoami
root
$ kill -9 1234
…cannot kill 1234 if it is in another container!
unshare(CLONE_NEWPID);
if (fork() == 0) {
assert(getpid() == 1);
execv("/bin/init");
}
1234 in one container is not the same user in another!unshare(CLONE_NEWUSER);
if (fork() == 0) {
setuid(0); /* I'm root now!...in my own little domain */
assert(getuid() == 0);
execv("/bin/init");
}
chroot(path)- Set the/of the FS for this process to bepath.
Now all files I can access are in the subdirectory path.
chroot("/home/gparmer/myroot/");
chdir("/");
unshare(CLONE_NEWPID | CLONE_NEWUSER);
if (fork() == 0) {
/* assuming `init` was originally in /home/gparmer/myroot/bin/init */
execv("/bin/init");
}
Linux uses pivot_root(new_root, old_path) (link) instead of chroot (why). See the code in Docker.
Service (daemon) created by systemd
dockerdawaits commands on a domain socket @ /var/run/docker.sock
| Goal | Containers | Android |
|---|---|---|
| Namespace Mgmt. | Separate all namespaces | Intents for shared services |
| App Isolation | Namespace separation = isolation | uid separation |
| Dependency Mgmt. | Container includes set of dependencies | App compiled for Android version |