aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2015-12-01 18:20:02 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2015-12-02 10:20:15 -0600
commit9fedb3b40b5983372b2c2de29dfe321c6dfaadf4 (patch)
tree70ea1b9d57ab7abc3ade81e7639cd05de111141d
parent635e33cdc8f18bb290756633ce0714c496383cfb (diff)
Add detection for docker containers
-rw-r--r--etc/rc.conf.Linux1
-rw-r--r--man/openrc-run.82
-rw-r--r--src/librc/librc.c4
-rw-r--r--src/librc/rc.h.in1
4 files changed, 8 insertions, 0 deletions
diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux
index f04f96ef..0865075b 100644
--- a/etc/rc.conf.Linux
+++ b/etc/rc.conf.Linux
@@ -3,6 +3,7 @@
# This is the subsystem type. Valid options on Linux:
# "" - nothing special
+# "docker" - Docker container manager
# "lxc" - Linux Containers
# "openvz" - Linux OpenVZ
# "prefix" - Prefix
diff --git a/man/openrc-run.8 b/man/openrc-run.8
index 12c1919b..9e0e7763 100644
--- a/man/openrc-run.8
+++ b/man/openrc-run.8
@@ -223,6 +223,8 @@ Same as -jail, but for VServer systems.
Same as -jail, but for Xen DOM0 systems.
.It Dv -xenu
Same as -jail, but for Xen DOMU systems.
+.It Dv -docker
+Same as -jail, but for docker systems.
.El
.El
.Pp
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 5e5de8d8..cad80333 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -269,6 +269,8 @@ rc_sys(void)
return RC_SYS_LXC;
if (strcmp(systype, RC_SYS_SYSTEMD_NSPAWN) == 0)
return RC_SYS_SYSTEMD_NSPAWN;
+ if (strcmp(systype, RC_SYS_DOCKER) == 0)
+ return RC_SYS_DOCKER;
}
if (exists("/proc/xen")) {
if (file_regex("/proc/xen/capabilities", "control_d"))
@@ -288,6 +290,8 @@ rc_sys(void)
return RC_SYS_LXC;
else if (file_regex("/proc/1/environ", "container=systemd-nspawn"))
return RC_SYS_SYSTEMD_NSPAWN;
+ else if (file_regex("/proc/1/environ", "container=docker"))
+ return RC_SYS_DOCKER;
#endif
return NULL;
diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
index 141ecb97..360c26a1 100644
--- a/src/librc/rc.h.in
+++ b/src/librc/rc.h.in
@@ -329,6 +329,7 @@ bool rc_service_daemons_crashed(const char *);
/*! @name System types
* OpenRC can support some special sub system types, normally virtualization.
* Some services cannot work in these systems, or we do something else. */
+#define RC_SYS_DOCKER "DOCKER"
#define RC_SYS_JAIL "JAIL"
#define RC_SYS_OPENVZ "OPENVZ"
#define RC_SYS_LXC "LXC"