You start with something simple:
Mount your project folder into a container to access your files.
Everything looks perfect... so why worry?
Welcome to the fascinating world of Linux mount propagation, rootless containers, and the subtle dance between namespaces! This guide will take you on a journey through one of the more esoteric corners of container technology.
Mount propagation is a Linux kernel feature that controls how mount events flow between different mount namespaces. Think of it as the "gossip protocol" for filesystems.
| Mode | Behavior | Use Case |
|---|---|---|
| shared | Mount events propagate bidirectionally between peer groups | When you want containers to see host mounts (and vice versa) |
| private | Mount events do not propagate at all | Complete isolation (default for security) |
| slave | Receives mount events from master, but doesn't send them back | One-way visibility (container sees host, host doesn't see container) |
# Check current propagation mode
findmnt -o TARGET,PROPAGATION /
# Output examples:
# TARGET PROPAGATION
# / shared β Mount events can propagate
# / private β Mount events stay isolated
Rootless containers are containers that run without requiring root privileges on the host system. This is a major security improvement over traditional container runtimes.
Rootless containers rely heavily on user namespaces, which allow UID/GID remapping:
WARN[0000] "/" is not a shared mount, this could cause issues or missing mounts with rootless containers
When Podman issues this warning, it's telling you:
/) has propagation mode set to privateMount your project folder into a container to access your files.
Everything looks perfect... so why worry?
Your CI/CD pipeline tries to build a container image from inside the container and suddenly...
The inner Docker can't see your mounted files properly!
Your pod needs to access host data, but when it tries to create additional mounts...
Kubernetes can't work with your bind mount!
Your hot-reload dev server should detect file changes, but...
File watching breaks with the wrong mount type!
Your rsync backup should create efficient hard links, but fails with...
Hard links don't work across private mounts!
Files are visible but you can't do advanced operations
Everything works - all operations supported
podman run -v /home/user/project:/work
podman run -v /home/user/project:/work:rshared
The :rshared flag tells Podman to share the mount properly, enabling all advanced operations.
Simple file access, basic scripts
Hot reload, file watchers, dev servers
Container-in-Container, Kubernetes, CI/CD
rsync, hard links, advanced tools
You bind-mount directories that contain other mount points
mount --bind /home/user /workYou're running containers that expect to see systemd mounts
podman run --systemdYou're using FUSE filesystems inside bind-mounted paths
sshfs user@server:/data /mnt/remoteYou're doing Docker-in-Docker or Kubernetes-in-Docker scenarios
docker run -v /var/run/docker.sock:/var/run/docker.sockYou mount Windows drives into containers in WSL2
podman run -v /mnt/c:/work
WSL2 is not native Linuxβit's a lightweight virtual machine running a real Linux kernel, managed by Windows. This architecture has implications for mount propagation:
/ in WSL2 is typically mounted with private propagation by default/mnt/c, /mnt/d etc. are special mounts using 9p/virtiofs protocol/mnt/c/Users/YourName/project into a container often fails or behaves strangely/mnt/c mount itself has complex propagation rules/mnt/c/Users/YourName/project
/home/youruser/project
# Check root propagation
findmnt -o TARGET,PROPAGATION /
# Check Windows mount propagation
findmnt -o TARGET,PROPAGATION /mnt/c
# See all mount propagation settings
findmnt -o TARGET,PROPAGATION | grep -E '(shared|private|slave)'
Changing mount propagation from private to shared has security implications, though they're often modest for single-user development environments.
With shared propagation, mount events created in one namespace can become visible in another. A malicious container with sufficient capabilities could potentially create mounts that affect the host.
Mitigation: Rootless containers have limited capabilities by default.
A compromised container might try to create confusing mount points that trick other processes or containers into accessing unexpected filesystems.
Mitigation: Requires CAP_SYS_ADMIN within the namespace, which rootless containers don't have over the host.
Shared propagation could allow a container to observe mount/unmount events on the host, potentially revealing information about system activity.
Mitigation: This is mostly metadata leakage, not direct file access.
If you run containers with --privileged or --cap-add=SYS_ADMIN, shared propagation significantly increases the attack surface.
Mitigation: Avoid privileged containers unless absolutely necessary.
| Scenario | Risk Level | Recommendation |
|---|---|---|
| Single-user dev machine, rootless containers only | π’ Low | Shared propagation is generally fine |
| WSL2 on personal Windows machine | π’ Low | Shared propagation is acceptable |
| Multi-user server, rootless containers | π‘ Medium | Evaluate based on trust model |
| Any system with privileged containers | π΄ High | Keep private, or carefully audit |
| Production servers | π΄ High | Use orchestration (K8s) with proper isolation |
mount /dev/sda1 /mnt
mount --bind /etc/shadow /tmp/shadow
echo "hack" > /etc/passwd
ip addr add 192.168.1.100/24 eth0
mount -t tmpfs tmpfs /tmp/test
fuse-overlayfs /merged
mkdir /app/data
echo "data" > /app/data/file.txt
npm start
python app.py
java -jar app.jar
# Make root filesystem shared (temporary)
sudo mount --make-rshared /
# Verify the change
findmnt -o TARGET,PROPAGATION /
# Should now show: / shared
# Test with Podman
podman ps -a # Warning should be gone
Create a startup script that runs automatically when WSL2 starts:
# Create a startup script
sudo tee /usr/local/bin/fix-mount-propagation.sh > /dev/null <<'EOF'
#!/bin/bash
mount --make-rshared /
EOF
# Make it executable
sudo chmod +x /usr/local/bin/fix-mount-propagation.sh
# Add to /etc/wsl.conf to run on startup
sudo tee -a /etc/wsl.conf > /dev/null <<'EOF'
[boot]
command = /usr/local/bin/fix-mount-propagation.sh
EOF
# Restart WSL2 from PowerShell/CMD:
# wsl --shutdown
# wsl
-v or --mount flags
podman volume create mydata
podman run -v mydata:/data myapp
FROM node:18
WORKDIR /app
COPY . .
CMD ["npm", "start"]
/home/user/projects/myapp
/mnt/c/Users/user/projects/myapp
FROM node:18 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:18-alpine
COPY --from=builder /app/dist /app
CMD ["node", "dist/server.js"]
# After applying fix, verify:
# 1. Check propagation
findmnt -o TARGET,PROPAGATION /
# 2. Test with Podman
podman run --rm -v /tmp:/test alpine ls /test
# 3. Check for warning
podman ps -a 2>&1 | grep "not a shared mount"
# (Should return nothing if fixed)
| Factor | Ignore Warning | Fix It |
|---|---|---|
| Bind Mount Usage | None or simple files only | Complex directory trees with nested mounts |
| Container Complexity | Single-process containers | Multi-service, systemd, or orchestration |
| Development Stage | Learning, experimenting | Production-like testing, CI/CD |
| Time Investment | Want to keep things simple | Need everything to work perfectly |
| WSL2 Restart Frequency | Restart often (temporary fix annoying) | Long-running sessions (fix once, forget) |
Running React app with hot reload
docker run -v ./src:/app/src node-app
Testing Kubernetes manifests locally
kind create cluster --config kind.yaml
Analyzing data from Windows drive
docker run -v /mnt/c/Data:/data jupyter
/home/user/data for better performanceRunning ready-made containers
docker run postgres redis nginx
Like many warnings in the Linux world, "/" is not a shared mount is informational rather than critical. It's telling you about a potential edge case that might affect you if you use certain advanced container features.
For most developers running simple containers in WSL2, this warning is harmless background noise. But if you're doing complex mount operations or hitting mysterious issues, now you know exactly what's happening and how to fix it.