aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2016-07-31 12:24:56 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2016-07-31 12:24:56 -0500
commitca8c29ee60b0e8ca89091aaf801725bd71e28001 (patch)
tree5768ba42d9a516fe00f293c934f26f7db06069cf /src
parentf62253b8334a85dac4671e42817b96a3bedd1881 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/librc/librc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 3e1f0d83..fdde3d5a 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