commit: 40d3795fbacc70349a52efc670a22458f4e2d7c4
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Jul 31 17:24:56 2016 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sun Jul 31 18:50:05 2016 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=40d3795f
librc: fix Docker auto detection
The original auto detection of Docker containers assumed the presence of
a container environment variable. However, Docker-1.12 does not
implement this, and I'm not sure which versions of docker implemented
it.
The new test is for the presence of a file named .dockerenv in the
root directory.
src/librc/librc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 3e1f0d8..fdde3d5 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -285,6 +285,9 @@ detect_container(const char *systype)
return RC_SYS_RKT;
else if (file_regex("/proc/1/environ", "container=systemd-nspawn"))
return RC_SYS_SYSTEMD_NSPAWN;
+ else if (exists("/.dockerenv"))
+ return RC_SYS_DOCKER;
+ /* old test, I'm not sure when this was valid. */
else if (file_regex("/proc/1/environ", "container=docker"))
return RC_SYS_DOCKER;
#endif