TheLarkInn / is-docker

Checks if the process is running inside a Docker container. Rust implementation of `sindresorhus/is-docker`
MIT License
5 stars 2 forks source link

Doesn't detect Docker Rootless #4

Open fenollp opened 9 months ago

llamaha commented 4 months ago

I'm unable to reproduce this. I'm running Docker in rootless mode. It will check for a .dockerenv file in the root and mine is there. It does a second check for the string "docker" in /proc/self/cgroup and that is there too.

How did you install docker rootless? Is there anything special about your configuration?

$ docker info | grep rootless-mode
WARNING: Running in rootless-mode without cgroups. To enable cgroups in rootless-mode, you need to boot the system in cgroup v2 mode.

$ docker run -it is_docker bash
root@8fa6c2872024:/# cargo run --example main
Currently in a Docker Container!

root@8fa6c2872024:/# ls -l .dockerenv 
-rwxr-xr-x 1 root root 0 Jul  3 09:12 .dockerenv

root@8fa6c2872024:/# grep docker /proc/self/cgroup
1:name=systemd:/user.slice/user-1000.slice/user@1000.service/docker.service/8fa6c28720242abf9fbeac968d7c27c482a79a623ec7c8c2e2140139f7d32071
0::/user.slice/user-1000.slice/user@1000.service/docker.service