All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Webster <Awebster@arcx.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v6 3/3] docker-engine: new package
Date: Wed, 8 Jun 2016 15:29:53 +0000	[thread overview]
Message-ID: <6f608608c76e4ebd82e22c93ea6add8d@WEBMAIL.arcx.com> (raw)
In-Reply-To: <20160607224744.5ed22c32@free-electrons.com>

Here is a patch with the init file I used.  I copied the contrib/init/sysvinit-debian/docker file and modified it slightly.

In start), the stdout/stderr of start-stop-daemon is logged to $DOCKER_LOGFILE.  I suspect that the intention was to actually log the stdout/stderr of docker, not start-stop-daemon, but I have left it as it was in the original file.

Author: Andrew Webster <awebster@arcx.com>
Date:   Mon Jun 6 14:53:08 2016 -0400

    docker-engine: switch sysv init to custom file
    
    The packaged redhat init file is not suitable for buildroot.
    This adds a customized version for buildroot.

    Signed-off-by: Andrew Webster <awebster@arcx.com>

diff --git a/package/docker-engine/docker-engine.mk b/package/docker-engine/docker-engine.mk
index b7407b2..17e4516 100644
--- a/package/docker-engine/docker-engine.mk
+++ b/package/docker-engine/docker-engine.mk
@@ -86,10 +86,10 @@ define DOCKER_ENGINE_INSTALL_INIT_SYSTEMD
 endef
 
 define DOCKER_ENGINE_INSTALL_INIT_SYSV
-    $(INSTALL) -D -m 755 $(@D)/contrib/init/sysvinit-redhat/docker \
+    $(INSTALL) -D -m 755 package/docker-engine/docker.init \
         $(TARGET_DIR)/etc/init.d/S61docker
-    $(INSTALL) -D -m 644 $(@D)/contrib/init/sysvinit-redhat/docker.sysconfig \
-        $(TARGET_DIR)/etc/sysconfig/docker.sysconfig
+    $(INSTALL) -D -m 644 $(@D)/contrib/init/sysvinit-debian/docker.default \
+        $(TARGET_DIR)/etc/default/docker
 endef
 
 define DOCKER_ENGINE_USERS
diff --git a/package/docker-engine/docker.init b/package/docker-engine/docker.init
new file mode 100755
index 0000000..9efa925
--- /dev/null
+++ b/package/docker-engine/docker.init
@@ -0,0 +1,111 @@
+#!/bin/sh
+set -e
+
+### BEGIN INIT INFO
+# Provides:           docker
+# Required-Start:     $syslog $remote_fs
+# Required-Stop:      $syslog $remote_fs
+# Should-Start:       cgroupfs-mount cgroup-lite
+# Should-Stop:        cgroupfs-mount cgroup-lite
+# Default-Start:      2 3 4 5
+# Default-Stop:       0 1 6
+# Short-Description:  Create lightweight, portable, self-sufficient containers.
+# Description:
+#  Docker is an open-source project to easily create lightweight, portable,
+#  self-sufficient containers from any application. The same container that a
+#  developer builds and tests on a laptop can run at scale, in production, on
+#  VMs, bare metal, OpenStack clusters, public clouds and more.
+### END INIT INFO
+
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+
+BASE=docker
+
+DOCKER=/usr/bin/$BASE
+# This is the pid file managed by docker itself
+DOCKER_PIDFILE=/var/run/$BASE.pid
+# This is the pid file created/managed by start-stop-daemon
+DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
+DOCKER_LOGFILE=/var/log/$BASE.log
+DOCKER_OPTS=
+DOCKER_DESC="Docker"
+
+if [ -f /etc/default/$BASE ]; then
+    . /etc/default/$BASE
+fi
+
+# Check docker is present
+if [ ! -x $DOCKER ]; then
+    echo "$DOCKER not present or not executable"
+    exit 1
+fi
+
+cgroupfs_mount() {
+    # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
+    if grep -v '^#' /etc/fstab | grep -q cgroup \
+        || [ ! -e /proc/cgroups ] \
+        || [ ! -d /sys/fs/cgroup ]; then
+        return
+    fi
+    if ! mountpoint -q /sys/fs/cgroup; then
+        mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
+    fi
+    (
+        cd /sys/fs/cgroup
+        for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
+            mkdir -p $sys
+            if ! mountpoint -q $sys; then
+                if ! mount -n -t cgroup -o $sys cgroup $sys; then
+                    rmdir $sys || true
+                fi
+            fi
+        done
+    )
+}
+
+case "$1" in
+    start)
+        cgroupfs_mount
+
+        ulimit -n 1048576
+        if [ "$BASH" ]; then
+            ulimit -u 1048576
+        else
+            ulimit -p 1048576
+        fi
+
+        echo "Starting $DOCKER_DESC: $BASE"
+        start-stop-daemon --start --background \
+            --exec "$DOCKER" \
+            --pidfile "$DOCKER_SSD_PIDFILE" \
+            --make-pidfile \
+            -- \
+                daemon -p "$DOCKER_PIDFILE" \
+                $DOCKER_OPTS \
+                    >> "$DOCKER_LOGFILE" 2>&1
+        echo $?
+        ;;
+
+    stop)
+        echo "Stopping $DOCKER_DESC: $BASE"
+        start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE" --retry 10
+        echo $?
+        ;;
+
+    restart)
+        docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
+        [ -n "$docker_pid" ] \
+            && ps -p $docker_pid > /dev/null 2>&1 \
+            && $0 stop
+        $0 start
+        ;;
+
+    force-reload)
+        $0 restart
+        ;;
+
+    *)
+        echo "Usage: service docker {start|stop|restart}"
+        exit 1
+        ;;
+esac

  reply	other threads:[~2016-06-08 15:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-28 22:46 [Buildroot] [PATCH v6 0/3] Add docker engine support Christian Stewart
2016-05-28 22:46 ` [Buildroot] [PATCH v6 1/3] runc: new package Christian Stewart
2016-07-04 16:29   ` Romain Naour
2016-05-28 22:46 ` [Buildroot] [PATCH v6 2/3] docker-containerd: " Christian Stewart
2016-06-07 20:15   ` Andrew Webster
2016-06-07 20:24     ` Christian Stewart
2016-07-04 17:43   ` Romain Naour
2016-05-28 22:46 ` [Buildroot] [PATCH v6 3/3] docker-engine: " Christian Stewart
2016-06-07 19:43   ` Andrew Webster
2016-06-07 19:54     ` Thomas Petazzoni
2016-06-07 20:10       ` Andrew Webster
2016-06-07 20:18       ` Christian Stewart
2016-06-07 20:37         ` Andrew Webster
2016-06-07 20:47           ` Thomas Petazzoni
2016-06-08 15:29             ` Andrew Webster [this message]
2016-06-27 23:02               ` Christian Stewart
2016-06-28 15:21                 ` Andrew Webster
2016-06-28 17:20                   ` Christian Stewart
2016-07-04 16:13   ` Romain Naour
2016-07-04 16:16     ` Christian Stewart
2016-07-04 17:45       ` Romain Naour
2016-06-27 22:22 ` [Buildroot] [PATCH v6 0/3] Add docker engine support Christian Stewart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f608608c76e4ebd82e22c93ea6add8d@WEBMAIL.arcx.com \
    --to=awebster@arcx.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.