[OpenWrt-Devel] [PATCH v2] procd: add docker support

Paul Spooren mail at aparcar.org
Mon May 27 05:33:29 EDT 2019


detects if running in a docker container, which then requires special
treatment of mounts. OpenWrt within Docker is useful for CI testing.

Signed-off-by: Paul Spooren <mail at aparcar.org>
---
 container.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/container.h b/container.h
index d33fa32..dd2e432 100644
--- a/container.h
+++ b/container.h
@@ -16,9 +16,11 @@
 
 #include <stdlib.h>
 #include <stdbool.h>
+#include <sys/stat.h>
 
 static inline bool is_container() {
-	return !!getenv("container");
+	struct stat s;
+	return !!getenv("container") || !!stat("/.dockerenv", &s);
 }
 
 #endif
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list