From ca8c29ee60b0e8ca89091aaf801725bd71e28001 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Sun, 31 Jul 2016 12:24:56 -0500 Subject: 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(+) (limited to 'src') 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 -- cgit v1.2.3