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.
This commit is contained in:
parent
f62253b833
commit
ca8c29ee60
@ -285,6 +285,9 @@ detect_container(const char *systype)
|
|||||||
return RC_SYS_RKT;
|
return RC_SYS_RKT;
|
||||||
else if (file_regex("/proc/1/environ", "container=systemd-nspawn"))
|
else if (file_regex("/proc/1/environ", "container=systemd-nspawn"))
|
||||||
return RC_SYS_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"))
|
else if (file_regex("/proc/1/environ", "container=docker"))
|
||||||
return RC_SYS_DOCKER;
|
return RC_SYS_DOCKER;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user