Browse Source

procd: add docker support

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@aparcar.org>
Paul Spooren 4 years ago
parent
commit
7f0f6b2a73
1 changed files with 3 additions and 1 deletions
  1. 3 1
      container.h

+ 3 - 1
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