]> git.pld-linux.org Git - packages/docker.git/blame - docker.init
add note why docker "daemon" doesn't fork
[packages/docker.git] / docker.init
CommitLineData
345101bd
ER
1#!/bin/sh
2#
51de77f0 3# Create lightweight, portable, self-sufficient containers.
345101bd 4#
09414b03 5# chkconfig: 345 20 80
345101bd 6#
51de77f0
ER
7# description: Docker is an open-source project to easily create lightweight, portable, \
8# self-sufficient containers from any application. The same container that a \
9# developer builds and tests on a laptop can run at scale, in production, on \
10# VMs, bare metal, OpenStack clusters, public clouds and more. \
345101bd
ER
11# processname: docker
12# pidfile: /var/run/docker.pid
13#
14
15# Source function library
16. /etc/rc.d/init.d/functions
17
18# Get network config
19. /etc/sysconfig/network
20
21# Check that networking is up.
22if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
47009a45 24 msg_network_down "Docker"
345101bd
ER
25 exit 1
26 fi
27else
28 exit 0
29fi
30
31# Get service config - may override defaults
47009a45 32[ -f /etc/sysconfig/docker ] && . /etc/sysconfig/docker
345101bd
ER
33
34pidfile="/var/run/docker.pid"
35
36start() {
37 # Check if the service is already running?
47009a45
ER
38 if [ -f /var/lock/subsys/docker ]; then
39 msg_already_running "Docker"
345101bd
ER
40 return
41 fi
42
c301aaa7
ER
43 # NOTE: docker daemon actually doesn't go to background, need to do that ourselves
44 # https://github.com/docker/docker/issues/2758
45
47009a45 46 msg_starting "Docker"
bab24a18 47 daemon --fork /usr/bin/docker daemon $OPTIONS
345101bd 48 RETVAL=$?
47009a45 49 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/docker
345101bd
ER
50}
51
52stop() {
47009a45
ER
53 if [ ! -f /var/lock/subsys/docker ]; then
54 msg_not_running "Docker"
345101bd
ER
55 return
56 fi
57
58 # Stop daemons.
47009a45 59 msg_stopping "Docker"
b16e11f6 60 killproc --pidfile $pidfile docker
47009a45 61 rm -f /var/lock/subsys/docker
345101bd
ER
62}
63
64condrestart() {
47009a45
ER
65 if [ ! -f /var/lock/subsys/docker ]; then
66 msg_not_running "Docker"
345101bd
ER
67 RETVAL=$1
68 return
69 fi
70
71 stop
72 start
73}
74
75RETVAL=0
76# See how we were called.
77case "$1" in
78 start)
79 start
80 ;;
81 stop)
82 stop
83 ;;
84 restart)
85 stop
86 start
87 ;;
88 try-restart)
89 condrestart 0
90 ;;
91 force-reload)
92 condrestart 7
93 ;;
94 status)
47009a45 95 status --pidfile $pidfile docker docker
345101bd
ER
96 RETVAL=$?
97 ;;
98 *)
99 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
100 exit 3
101esac
102
103exit $RETVAL
This page took 0.083592 seconds and 4 git commands to generate.