Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running podman containers inside unprivileged (docker) container #4131

Closed
johanbrandhorst opened this issue Sep 27, 2019 · 69 comments
Closed
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue

Comments

@johanbrandhorst
Copy link

/kind feature

Description

Very similar to #4056 but with the exception that the host container is an unprivileged (docker) container.

The specific use case is being able to programmatically create and destroy containers while running inside an unprivileged container, for automated tests in CI environments such as CircleCI and Github actions.

The comments by @mheon (#4056 (comment)) imply this is currently impossible, and may never be possible, but I'd like to explore in more detail the feasibility of this separately from that issue.

The stack overflow discussion https://stackoverflow.com/q/56032747 seems to touch on the same problem, and unfortunately come to the same conclusion, that --privileged is required at this time, which makes it impossible to use in CircleCI and Github Actions.

Steps to reproduce the issue:

  1. Start an unprivileged container (with docker or podman)
  2. Install podman inside the container
  3. Try to run another container using podman inside the first container.

Describe the results you received:

At the moment the error I'm getting looks like this:

# podman run --rm -it ubuntu
ERRO[0000] unable to write system event: "write unixgram @00045->/run/systemd/journal/socket: sendmsg: no such file or directory" 
ERRO[0000] unable to write pod event: "write unixgram @00045->/run/systemd/journal/socket: sendmsg: no such file or directory" 
ERRO[0000] error creating network namespace for container fc189c2fb049f6d0955773f86245d7394e0a35181ca97c23782e4b17f8f66fba: mount --make-rshared /var/run/netns failed: "operation not permitted" 
ERRO[0000] unable to write pod event: "write unixgram @00045->/run/systemd/journal/socket: sendmsg: no such file or directory" 
Error: failed to mount shm tmpfs "/home/REDACTED/.local/share/containers/storage/vfs-containers/fc189c2fb049f6d0955773f86245d7394e0a35181ca97c23782e4b17f8f66fba/userdata/shm": operation not permitted

Describe the results you expected:

I expected to be able to run a container inside a container.

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

$ podman version
Version:            1.5.1
RemoteAPI Version:  1
Go Version:         go1.12.8
OS/Arch:            linux/amd64

Output of podman info --debug:

$ podman info --debug
debug:
  compiler: gc
  git commit: ""
  go version: go1.12.8
  podman version: 1.5.1
host:
  BuildahVersion: 1.10.1
  Conmon:
    package: Unknown
    path: /usr/bin/conmon
    version: 'conmon version 2.0.0, commit: e217fdff82e0b1a6184a28c43043a4065083407f'
  Distribution:
    distribution: manjaro
    version: unknown
  MemFree: 198766592
  MemTotal: 16569856000
  OCIRuntime:
    package: Unknown
    path: /usr/bin/runc
    version: |-
      runc version 1.0.0-rc8
      commit: 425e105d5a03fabd737a126ad93d62a9eeede87f
      spec: 1.0.1-dev
  SwapFree: 18179530752
  SwapTotal: 18223570944
  arch: amd64
  cpus: 8
  eventlogger: file
  hostname: REDACTED-x1
  kernel: 4.19.69-1-MANJARO
  os: linux
  rootless: true
  uptime: 22h 29m 13.05s (Approximately 0.92 days)
registries:
  blocked: null
  insecure: null
  search:
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.access.redhat.com
  - registry.centos.org
store:
  ConfigFile: /home/REDACTED/.config/containers/storage.conf
  ContainerStore:
    number: 1
  GraphDriverName: vfs
  GraphOptions: null
  GraphRoot: /home/REDACTED/.local/share/containers/storage
  GraphStatus: {}
  ImageStore:
    number: 1
  RunRoot: /run/user/1000
  VolumePath: /home/REDACTED/.local/share/containers/storage/volumes

Additional environment details (AWS, VirtualBox, physical, etc.):

Running on bare metal (laptop)

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 27, 2019
@AkihiroSuda
Copy link
Collaborator

This is possible with UML but extremely slow

https://github.com/weber-software/diuid

@johanbrandhorst
Copy link
Author

Thanks for the link @AkihiroSuda, however it doesn't seem like it supports running containers, in my testing.

$ podman run -it --rm  --cap-add=SYS_PTRACE weberlars/diuid docker run --rm -it ubuntu
Docker: Docker version 18.09.7, build 2d0083d
Kernel: 5.2.0
Rootfs: Debian GNU/Linux 9.9 (stretch)

Configuration: MEM=2G DISK=10G
[ ok ] Starting OpenBSD Secure Shell server: sshd.
Formatting /persistent/var_lib_docker.img
For better performance, consider mounting a tmpfs on /umlshm like this: `docker run --tmpfs /umlshm:rw,nosuid,nodev,exec,size=8g`
waiting for dockerd ...
$

I'm not sure if I'm doing something wrong, or maybe it doesn't support running inside podman (though there shouldn't be any difference, right?). If it's only for building docker images, it's not nearly as interesting to me.

@AkihiroSuda
Copy link
Collaborator

UML should be able to run containers. (both podman-in-docker and docker-in-podman)

Something seems wrong with either Podman or sysctl.

@johanbrandhorst
Copy link
Author

Ok thanks I will debug it a bit more!

@rhatdan
Copy link
Member

rhatdan commented Oct 3, 2019

@giuseppe Would this be possible with rootless containers running with fuse-overlay? We would need setuid and setgid to handle setting up a namespace.

We could try this out with podman in podman.

I think the issue with running podman in Docker is the tighter seccomp controls. Docker seccomp.json mistakenly blocks all mount syscalls, even though non privileged mount syscall is allowed for procfs, tmpfs, bind, fuse and sysfs, I believe.

@mheon
Copy link
Member

mheon commented Oct 3, 2019

I think UID/GID mapping will also be an issue.

You'll either need the storage flag to ignore chown errors, or a separate newuidmap/newgidmap setup within the container - and I suspect you won't have the privileges to run them in a rootless container.

@c-goes
Copy link

c-goes commented Oct 15, 2019

podman in LXD seems to work fine (unprivileged LXD container created with -c security.nesting=true, same option as for running Docker in LXD).
Only problem I have is creating rootless containers. There is an undescriptive error with slirp4netns.

Here is a debug log for rootless if it is any help for developing this feature.

$ podman run -it --log-level=debug k8s.gcr.io/busybox sh
DEBU[0000] using conmon: "/usr/libexec/podman/conmon"   
DEBU[0000] Initializing boltdb state at /home/ubuntu/.local/share/containers/storage/libpod/bolt_state.db 
DEBU[0000] Using graph driver overlay                   
DEBU[0000] Using graph root /home/ubuntu/.local/share/containers/storage 
DEBU[0000] Using run root /run/user/1000                
DEBU[0000] Using static dir /home/ubuntu/.local/share/containers/storage/libpod 
DEBU[0000] Using tmp dir /run/user/1000/libpod/tmp      
DEBU[0000] Using volume path /home/ubuntu/.local/share/containers/storage/volumes 
DEBU[0000] Set libpod namespace to ""                   
DEBU[0000] [graphdriver] trying provided driver "overlay" 
DEBU[0000] overlay: mount_program=/usr/bin/fuse-overlayfs 
DEBU[0000] backingFs=zfs, projectQuotaSupported=false, useNativeDiff=false, usingMetacopy=false 
DEBU[0000] Initializing event backend journald          
DEBU[0000] using runtime "/usr/lib/cri-o-runc/sbin/runc" 
WARN[0000] Error initializing configured OCI runtime crun: no valid executable found for OCI runtime crun: invalid argument 
DEBU[0000] Failed to add podman to systemd sandbox cgroup: dial unix /run/user/0/bus: connect: permission denied 
INFO[0000] running as rootless                          
DEBU[0000] using conmon: "/usr/libexec/podman/conmon"   
DEBU[0000] Initializing boltdb state at /home/ubuntu/.local/share/containers/storage/libpod/bolt_state.db 
DEBU[0000] Using graph driver overlay                   
DEBU[0000] Using graph root /home/ubuntu/.local/share/containers/storage 
DEBU[0000] Using run root /run/user/1000                
DEBU[0000] Using static dir /home/ubuntu/.local/share/containers/storage/libpod 
DEBU[0000] Using tmp dir /run/user/1000/libpod/tmp      
DEBU[0000] Using volume path /home/ubuntu/.local/share/containers/storage/volumes 
DEBU[0000] Set libpod namespace to ""                   
DEBU[0000] Initializing event backend journald          
WARN[0000] Error initializing configured OCI runtime crun: no valid executable found for OCI runtime crun: invalid argument 
DEBU[0000] using runtime "/usr/lib/cri-o-runc/sbin/runc" 
DEBU[0000] parsed reference into "[overlay@/home/ubuntu/.local/share/containers/storage+/run/user/1000:overlay.mount_program=/usr/bin/fuse-overlayfs]k8s.gcr.io/busybox:latest" 
DEBU[0000] parsed reference into "[overlay@/home/ubuntu/.local/share/containers/storage+/run/user/1000:overlay.mount_program=/usr/bin/fuse-overlayfs]@e7d168d7db455c45f4d0315d89dbd18806df4784f803c3cc99f8a2e250585b5b" 
DEBU[0000] [graphdriver] trying provided driver "overlay" 
DEBU[0000] overlay: mount_program=/usr/bin/fuse-overlayfs 
DEBU[0000] backingFs=zfs, projectQuotaSupported=false, useNativeDiff=false, usingMetacopy=false 
DEBU[0000] parsed reference into "[overlay@/home/ubuntu/.local/share/containers/storage+/run/user/1000:overlay.mount_program=/usr/bin/fuse-overlayfs]@e7d168d7db455c45f4d0315d89dbd18806df4784f803c3cc99f8a2e250585b5b" 
DEBU[0000] parsed reference into "[overlay@/home/ubuntu/.local/share/containers/storage+/run/user/1000:overlay.mount_program=/usr/bin/fuse-overlayfs]@e7d168d7db455c45f4d0315d89dbd18806df4784f803c3cc99f8a2e250585b5b" 
DEBU[0000] No hostname set; container's hostname will default to runtime default 
DEBU[0000] Using slirp4netns netmode                    
DEBU[0000] created OCI spec and options for new container 
DEBU[0000] Allocated lock 6 for container 14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85 
DEBU[0000] parsed reference into "[overlay@/home/ubuntu/.local/share/containers/storage+/run/user/1000:overlay.mount_program=/usr/bin/fuse-overlayfs]@e7d168d7db455c45f4d0315d89dbd18806df4784f803c3cc99f8a2e250585b5b" 
DEBU[0000] created container "14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" 
DEBU[0000] container "14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" has work directory "/home/ubuntu/.local/share/containers/storage/overlay-containers/14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85/userdata" 
DEBU[0000] container "14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" has run directory "/run/user/1000/overlay-containers/14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85/userdata" 
DEBU[0000] New container created "14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" 
DEBU[0000] container "14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" has CgroupParent "/libpod_parent/libpod-14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" 
DEBU[0000] Handling terminal attach                     
DEBU[0000] overlay: mount_data=lowerdir=/home/ubuntu/.local/share/containers/storage/overlay/l/S7XHB2WPYOR4RJSE7R7ISPTZXN:/home/ubuntu/.local/share/containers/storage/overlay/l/PZAPRTUCJVM3BFACSLRF3JFFJP:/home/ubuntu/.local/share/containers/storage/overlay/l/WIAN5K2O3J3IKJYKTA2UXGK5VP:/home/ubuntu/.local/share/containers/storage/overlay/l/Y6P37THEEBEEBA2JBV7N2B53KL,upperdir=/home/ubuntu/.local/share/containers/storage/overlay/cd035583578cbe64d5824a90217285db106a083087efff53d5b6e3aa2db983fe/diff,workdir=/home/ubuntu/.local/share/containers/storage/overlay/cd035583578cbe64d5824a90217285db106a083087efff53d5b6e3aa2db983fe/work 
DEBU[0000] mounted container "14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" at "/home/ubuntu/.local/share/containers/storage/overlay/cd035583578cbe64d5824a90217285db106a083087efff53d5b6e3aa2db983fe/merged" 
DEBU[0000] Created root filesystem for container 14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85 at /home/ubuntu/.local/share/containers/storage/overlay/cd035583578cbe64d5824a90217285db106a083087efff53d5b6e3aa2db983fe/merged 
DEBU[0000] Made network namespace at /run/user/1000/netns/cni-d09ac9e5-1983-ab8b-e33a-9a8e47e69a9b for container 14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85 
DEBU[0000] slirp4netns command: /usr/bin/slirp4netns --disable-host-loopback --mtu 65520 --enable-sandbox -c -e 3 -r 4 --netns-type=path /run/user/1000/netns/cni-d09ac9e5-1983-ab8b-e33a-9a8e47e69a9b tap0 
DEBU[0001] unmounted container "14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85" 
DEBU[0001] Tearing down network namespace at /run/user/1000/netns/cni-d09ac9e5-1983-ab8b-e33a-9a8e47e69a9b for container 14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85 
DEBU[0001] Cleaning up container 14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85 
DEBU[0001] Network is already cleaned up, skipping...   
DEBU[0001] Container 14bd288c9d7b8499371a3ee93f09f4cdcc57a77ff69bb3d4ddbe673d1bbeca85 storage is already unmounted, skipping... 
DEBU[0001] ExitCode msg: "slirp4netns failed"           
ERRO[0001] slirp4netns failed                           
WARN[0001] unable to find /home/ubuntu/.config/containers/registries.conf. some podman (image shortnames) commands may be limited 

@rhatdan
Copy link
Member

rhatdan commented Oct 16, 2019

@AkihiroSuda @giuseppe Ideas?

@giuseppe
Copy link
Member

Only problem I have is creating rootless containers. There is an undescriptive error with slirp4netns.

does the container work fine if you use --net=host?

@AkihiroSuda
Copy link
Collaborator

I reproduced the LXD issue.

slirp4netns sandbox doesn't seem to work on LXD with -c security.nesting=true.

slirp4netns --configure --mtu=65520 --disable-host-loopback $(cat /tmp/pid) --enable-sandbox tap0
WARNING: Support for sandboxing is experimental
sent tapfd=5 for tap0
received tapfd=5
Starting slirp
* MTU:             65520
* Network:         10.0.2.0
* Netmask:         255.255.255.0
* Gateway:         10.0.2.2
* DNS:             10.0.2.3
* Recommended IP:  10.0.2.100
cannot mount tmpfs on /tmp
create_sandbox failed
do_slirp is exiting
do_slirp failed
parent failed

does the container work fine if you use --net=host?

yes

@AkihiroSuda
Copy link
Collaborator

strace:

write(1, "* Recommended IP:  10.0.2.100\n", 30* Recommended IP:  10.0.2.100
) = 30
geteuid()                               = 1001
openat(AT_FDCWD, "/proc/3122/ns/user", O_RDONLY) = 3
setns(3, CLONE_NEWUSER)                 = 0
close(3)                                = 0
close(-1)                               = -1 EBADF (Bad file descriptor)
setresgid(-1, 0, -1)                    = 0
setresuid(-1, 0, -1)                    = 0
openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 3
read(3, "\357e]\207\35\203)\36@\253\273m\6\2415j", 16) = 16
close(3)                                = 0
futex(0x7f8c29790f68, FUTEX_WAKE_PRIVATE, 2147483647) = 0
brk(0x56140053e000)                     = 0x56140053e000
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f8c2945ff60}, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=0}, 8) = 0
unshare(CLONE_NEWNS)                    = 0
mount("", "/", 0x5614001c8d77, MS_PRIVATE, NULL) = 0
mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, "size=1k") = 0
mkdir("/tmp/etc", 0755)                 = 0
mkdir("/tmp/old", 0755)                 = 0
mkdir("/tmp/run", 0755)                 = 0
mount("/etc", "/tmp/etc", 0x5614001c8d77, MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_BIND|MS_REC|MS_SLAVE, NULL) = 0
mount("/etc", "/tmp/etc", 0x5614001c8d77, MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_REMOUNT|MS_BIND, NULL) = 0
mount("/run", "/tmp/run", 0x5614001c8d77, MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_BIND|MS_REC|MS_SLAVE, NULL) = 0
mount("/run", "/tmp/run", 0x5614001c8d77, MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_REMOUNT|MS_BIND, NULL) = 0
chdir("/tmp")                           = 0
pivot_root(".", "old")                  = 0
chdir("/")                              = 0
umount2("/old", MNT_DETACH)             = 0
rmdir("/old")                           = 0
mount("tmpfs", "/", 0x5614001c827f, MS_RDONLY|MS_REMOUNT, "size=0k") = -1 EACCES (Permission denied)
write(2, "cannot mount tmpfs on /tmp\n", 27cannot mount tmpfs on /tmp
) = 27
write(2, "create_sandbox failed\n", 22create_sandbox failed
) = 22
write(2, "do_slirp is exiting\n", 20do_slirp is exiting
)   = 20
brk(0x56140052e000)                     = 0x56140052e000
write(2, "do_slirp failed\n", 16do_slirp failed
)       = 16
close(5)                                = 0
write(2, "parent failed\n", 14parent failed
)         = 14
exit_group(1)                           = ?
+++ exited with 1 +++

@github-actions
Copy link

This issue had no activity for 30 days. In the absence of activity or the "do-not-close" label, the issue will be automatically closed within 7 days.

@mheon
Copy link
Member

mheon commented Nov 18, 2019 via email

@rhatdan
Copy link
Member

rhatdan commented Nov 18, 2019

Yes I have a working prototype of this, now, will publish a blog on it shortly. I think we could get some additional support into containers.conf to make this easier to do.

@johanbrandhorst
Copy link
Author

Just to be clear, the issue specifically mentions a use case:

The specific use case is being able to programmatically create and destroy containers while running inside an unprivileged container, for automated tests in CI environments such as CircleCI and Github actions.

Is this supported by the prototype?

@AkihiroSuda
Copy link
Collaborator

How is this possible? With seccomp=unconfined apparmor=unconfined?

@rhatdan
Copy link
Member

rhatdan commented Nov 18, 2019

Currently have to disable SELinux since by default it blocks a few commands I have a modified seccomp.json file also. BTW I have been sending out updates on podman.io mailing list.

Since I don't use apparmor, I would figure it is similar to SELinux. Main SELinux issues were on mounting file systems.

@github-actions
Copy link

This issue had no activity for 30 days. In the absence of activity or the "do-not-close" label, the issue will be automatically closed within 7 days.

@johanbrandhorst
Copy link
Author

Still being worked on

@rhatdan
Copy link
Member

rhatdan commented Dec 19, 2019

It has been back burnered especially until after the break.

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jan 19, 2020

This is the main PR to get this working.
#4698

@tvvignesh
Copy link

@rhatdan @AkihiroSuda Hi. I wanted to use Podman to build images in my Gitlab CI pipeline using Kubernetes executor and I have set a restricted PSP (Using exactly this: https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/restricted-psp.yaml) where no capabilities are added and root access is disabled.

Since the build is running in kubernetes directly, there is no docker involved, its directly running within unpriviliged containerd with no root access in Kubernetes.

I get the same error as mentioned:
Capture

And this is how the sample pipeline looks:

image: "quay.io/podman/stable"

buildah:
  tags:
    - development
    - ops
  variables:
    STORAGE_DRIVER: "vfs"
    BUILDAH_FORMAT: "docker"
    IMAGE_TAG: $CI_REGISTRY_IMAGE:edge
  script:
    - podman version
    - whoami
    - echo "Logging into $CI_REGISTRY"
    - podman login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - podman build -t ${IMAGE_TAG} .
    - podman images
    - podman push ${IMAGE_TAG}
    - podman logout $CI_REGISTRY

May I know how I can get this to work? Would it not work with the current PSP? Should I be changing something else? Thanks.

@marcofranssen
Copy link

marcofranssen commented Oct 13, 2020

I have been reading this thread, but kind of lack to see how I can run podman inside a docker container. From what I understand this is resolved in this PR #4698. Would be great if someone can point out the exact requirement to run podman successfully inside a docker container.

A docker-compose or cli example is very much appreciated.

Currently I run into the following issue

$ docker run --rm -it quay.io/podman/stable /bin/bash
$ podman pull alpine
Error: mount /var/lib/containers/storage/overlay:/var/lib/containers/storage/overlay, flags: 0x1000: operation not permitted

@rhatdan
Copy link
Member

rhatdan commented Oct 13, 2020

It would definitely need to be --privileged, and have a volume mounted on /var/lib/containers.

@marcofranssen
Copy link

So the PR mentioned above doesn't resolve yet the fact that a privileged container is required? E.g. for Github Actions or Gitlab CI. From a security point of view you can't really run a privileged container there.

@bbodiya-akamai
Copy link

bbodiya-akamai commented Oct 14, 2020

@marcofranssen, I'm not sure about the PR mentioned, but I have verified that podman now works in an unprivileged docker container with some caveats. One that tripped me up is that the host kernel must support deferred deletion. Here's a simple docker image that lets you check that quickly:

docker run -it --rm --cap-add SYS_ADMIN mbentley/check-deferred-deletion

Assuming that works, you can run podman in docker like this:

docker run --rm -ti \
--security-opt seccomp=unconfined \
--security-opt label=disable \
--cap-add SYS_ADMIN \
--cap-add SYS_RESOURCE \
--env STORAGE_DRIVER=vfs \
quay.io/podman/stable sh -c "podman run hello-world"

Edit:
I should also mention that overlay works too if you add /dev/fuse (mount to /var/lib/containers optional)

docker run --rm -ti \
--security-opt seccomp=unconfined \
--security-opt label=disable \
--cap-add SYS_ADMIN \
--cap-add SYS_RESOURCE \
--device /dev/fuse \
--mount=type=tmpfs,destination=/var/lib/containers
quay.io/podman/stable sh -c "podman run hello-world"

@smekkley
Copy link

buildah with chroot mode with vfs works in rootless podman. So building containers no longer requires root anymore thanks to podman/buildah. Naturally you can also run in buildah isolation mode, but it's just chroot and there are some gotchas.

@felipecrs
Copy link

felipecrs commented Oct 16, 2020

It also does not work with sysbox.

$ docker run --rm --runtime=sysbox-runc quay.io/podman/stable podman run hello-world
Trying to pull registry.fedoraproject.org/hello-world...
  manifest unknown: manifest unknown
Trying to pull registry.access.redhat.com/hello-world...
  name unknown: Repo not found
Trying to pull registry.centos.org/hello-world...
  manifest unknown: manifest unknown
Trying to pull docker.io/library/hello-world...
Getting image source signatures
Copying blob sha256:0e03bdcc26d7a9a57ef3b6f1bf1a210cff6239bff7c8cac72435984032851689
Copying config sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
Writing manifest to image destination
Storing signatures
time="2020-10-16T21:07:09Z" level=error msg="error unmounting /var/lib/containers/storage/overlay/68c6ae97224fb5a4a2f602ce295a0a09fb2860bdb3a4320338077065dc64bc59/merged: invalid argument"
Error: error mounting storage for container 8bbe8b1eb1e37035079cb309bbec9d507c1a4efda2ade4dbd8ae729a8a029b9b: error creating overlay mount to /var/lib/containers/storage/overlay/68c6ae97224fb5a4a2f602ce295a0a09fb2860bdb3a4320338077065dc64bc59/merged: using mount program /usr/bin/fuse-overlayfs: fuse: device not found, try 'modprobe fuse' first
fuse-overlayfs: cannot mount: No such file or directory
: exit status 1

@ctalledo, @rodnymolina maybe it's because podman uses /var/lib/containers rather than /var/lib/docker?

@rhatdan
Copy link
Member

rhatdan commented Oct 21, 2020

Podman is pulling down the content. @giuseppe Any ideas? This looks close.
Can you try
docker run --rm --device=/dev/fuse --runtime=sysbox-runc quay.io/podman/stable podman run hello-world

@felipecrs
Copy link

felipecrs commented Oct 21, 2020

A different error happens. :)

docker run --rm --device=/dev/fuse --runtime=sysbox-runc quay.io/podman/stable podman run hello-world
Trying to pull registry.fedoraproject.org/hello-world...
  manifest unknown: manifest unknown
Trying to pull registry.access.redhat.com/hello-world...
  name unknown: Repo not found
Trying to pull registry.centos.org/hello-world...
  manifest unknown: manifest unknown
Trying to pull docker.io/library/hello-world...
Getting image source signatures
Copying blob sha256:0e03bdcc26d7a9a57ef3b6f1bf1a210cff6239bff7c8cac72435984032851689
Copying config sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
Writing manifest to image destination
Storing signatures
Error: cannot chown /var/lib/containers/storage/overlay/765c5b5697c416f4ed9d1b577141466df3ab4afb60941e1b86b68506a3863cf8/merged to 0:0: chown /var/lib/containers/storage/overlay/765c5b5697c416f4ed9d1b577141466df3ab4afb60941e1b86b68506a3863cf8/merged: operation not permitted

@rhatdan
Copy link
Member

rhatdan commented Oct 22, 2020

I think seccomp rules from Docker are to tight.

Try with --security-opt seccomp=unconfined

Or use the seccomp.json file from Podman /usr/share/containers/seccomp.json

@rodnymolina
Copy link

@felipecrs, thanks for letting us know, i've filed this one to track Sysbox fix.

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@ShadowJonathan
Copy link

Any updates here?

@rhatdan
Copy link
Member

rhatdan commented Dec 7, 2020

This is a docker issue, not something that can be fixed in Podman.
Podman can run podman inside of a container, but Docker can not, without modifying their seccomp rules. BTW Docker can not run Docker within a Container either.

@rhatdan rhatdan closed this as completed Dec 7, 2020
@felipecrs
Copy link

So,

podman run --rm quay.io/podman/stable podman run hello-world

Was supposed to work?

@rhatdan
Copy link
Member

rhatdan commented Dec 7, 2020

Not quite. Sadly that seems broken now, I will play around with it.

@smekkley
Copy link

This works (rootless privileged),
podman run --privileged --net=host --rm quay.io/podman/stable podman run --net=host --storage-driver=vfs hello-world

But this doesn't. (rootfull non-privileged)
sudo podman run --net=host --rm quay.io/podman/stable podman run --net=host --storage-driver=vfs hello-world

I believe if the latter is solved it'll work for docker as well.

@ctalledo
Copy link

ctalledo commented Feb 28, 2021

If anyone has cycles to help us improve Sysbox (a new type of runc), then running Podman inside unprivileged containers (deployed by Docker, Podman, or even K8s) should be doable and not too difficult to implement.

Docker + Sysbox containers can already run Docker, systemd, and even K8s inside unprivileged (rootless) containers. And do so without requiring the vfs driver (i.e., using the native overlayfs driver).

@giuseppe
Copy link
Member

giuseppe commented Mar 1, 2021

@ctalledo is there anything that doesn't work if we just use podman --runtime /path/to/sysbox ....?

@rodnymolina
Copy link

@giuseppe, last time i checked podman worked to instantiate outer containers, but there are a few things we need to iron out to claim full support, such as the uid-mapping approach to follow to be able to instantiate inner containers either with podman or docker (not working right now w/o hacks). As Cesar said, we are not that far off, need some more time (or help :-) to have it done.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue
Projects
None yet
Development

No branches or pull requests