Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rootlesskit

> 编程语言
Open source

Linux-native "fake root" for implementing rootless containers

1.3K stars0 likes0 views
WebsiteGitHub

About

Linux-native "fake root" for implementing rootless containers

RootlessKit: Linux-native fakeroot using user namespaces

RootlessKit is a Linux-native implementation of "fake root" using user_namespaces(7).

The purpose of RootlessKit is to run Docker and Kubernetes as an unprivileged user (known as "Rootless mode"), so as to protect the real root on the host from potential container-breakout attacks.

  • What RootlessKit actually does
  • Similar projects
  • Projects using RootlessKit
  • Setup
    • Requirements
    • subuid
    • sysctl
  • Usage
  • Full CLI options
  • State directory
  • Environment variables
  • Additional documents

What RootlessKit actually does

RootlessKit creates user_namespaces(7) and mount_namespaces(7), and executes newuidmap(1)/newgidmap(1) along with subuid(5) and subgid(5).

RootlessKit also supports isolating network_namespaces(7) with userspace NAT using "slirp". Kernel-mode NAT using SUID-enabled lxc-user-nic(1) is also experimentally supported.

Similar projects

Tools based on LD_PRELOAD (not enough to run rootless containers and yet lacks support for static binaries):

  • fakeroot

Tools based on ptrace(2) (not enough to run rootless containers and yet slow):

  • fakeroot-ng
  • proot

Tools based on user_namespaces(7) (as in RootlessKit, but without support for --copy-up, --net, ...):

  • unshare -r
  • podman unshare
  • become-root

Projects using RootlessKit

Container engines:

  • Docker/Moby
  • Podman (since Podman v1.8.0)
  • nerdctl: Docker-compatible CLI for containerd
  • iSulad: a lightweight container engine

Container image builders:

  • BuildKit: Next-generation docker build backend

Kubernetes distributions:

  • Usernetes: Docker & Kubernetes, installable under a non-root user's $HOME.
  • k3s: Lightweight Kubernetes

Setup

Run make && sudo make install .

The following binaries will be installed:

  • /usr/local/bin/rootlesskit
  • /usr/local/bin/rootlessctl
  • /usr/local/bin/rootlesskit-docker-proxy (DEPRECATED; Only required for Docker prior to v28)

Requirements

subuid

  • newuidmap and newgidmap need to be installed on the host. These commands are provided by the uidmap package on most distributions.

  • /etc/subuid and /etc/subgid should contain more than 65536 sub-IDs. e.g. penguin:231072:65536. These files are automatically configured on most distributions.

bash
$ id -u
1001
$ whoami
penguin
$ grep "^$(whoami):" /etc/subuid
penguin:231072:65536
$ grep "^$(whoami):" /etc/subgid
penguin:231072:65536

See also https://rootlesscontaine.rs/getting-started/common/subuid/

sysctl

Old distros may require setting up sysctl such as kernel.unprivileged_userns_clone=1: See .

AppArmor

On Ubuntu 24.04 or later, the rootlesskit binary is expected to be exactly under /usr/bin. To install rootlesskit on other paths such as /usr/local/bin, you need to install a custom AppArmor profile. See .

Usage

Inside rootlesskit bash, your UID is mapped to 0 but it is not the real root:

bash
(host)$ rootlesskit bash
(rootlesskit)# id
uid=0(root) gid=0(root) groups=0(root),65534(nogroup)
(rootlesskit)# ls -l /etc/shadow
-rw-r----- 1 nobody nogroup 1050 Aug 21 19:02 /etc/shadow
(rootlesskit)# cat /etc/shadow
cat: /etc/shadow: Permission denied

Environment variables are kept untouched:

bash
(host)$ rootlesskit bash
(rootlesskit)# echo $USER
penguin
(rootlesskit)# echo $HOME
/home/penguin
(rootlesskit)# echo $XDG_RUNTIME_DIR
/run/user/1001

Filesystems can be isolated from the host with --copy-up:

bash
(host)$ rootlesskit --copy-up=/etc bash
(rootlesskit)# rm /etc/resolv.conf
(rootlesskit)# vi /etc/resolv.conf

You can even create network namespaces with Slirp:

bash
(host)$ rootlesskit --copy-up=/etc --copy-up=/run --net=slirp4netns --disable-host-loopback bash
(rootleesskit)# ip netns add foo
...

Full CLI options

…

State directory

The following files will be created in the state directory, which can be specified with --state-dir:

  • lock: lock file
  • child_pid: decimal PID text that can be used for nsenter(1).
  • api.sock: REST API socket. See ./docs/api.md and ./docs/port.md.
  • netns (since v2.0.0): Detached NetNS. Created only with --detach-netns. Valid only in the child mount namespace.
  • resolv.conf (since v2.0.0): resolv.conf file. Bind-mounted to /etc/resolv.conf unles --detach-netns is specified.
  • hosts (since v2.0.0): hosts file. Bind-mounted to /etc/hosts unless --detach-netns is specified.

If --state-dir is not specified, RootlessKit creates a temporary state directory on /tmp and removes it on exit.

Undocumented files are subject to change.

Environment variables

The following environment variables will be set for the child process:

  • ROOTLESSKIT_STATE_DIR (since v0.3.0): absolute path to the state dir
  • ROOTLESSKIT_PARENT_EUID (since v0.8.0): effective UID
  • ROOTLESSKIT_PARENT_EGID (since v0.8.0): effective GID

Undocumented environment variables are subject to change.

Additional documents

  • ./docs/network.md: Networking (--net, --mtu, --cidr, --disable-host-loopback, --slirp4netns-*, ...)
  • ./docs/port.md: Port forwarding (--port-driver, -p, ...)
  • ./docs/mount.md: Mount (--propagation, ...)
  • ./docs/process.md: Process (--pidns, --reaper, --cgroupns, --evacuate-cgroup2, ...)
  • ./docs/api.md: REST API
  • ./docs/subid.md: Sub UIDs and sub GIDs

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gorootless-containers

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言