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