]> git.pld-linux.org Git - packages/docker.git/blob - docker.init
setup bigger ulimits like contrib/init
[packages/docker.git] / docker.init
1 #!/bin/sh
2 #
3 # Create lightweight, portable, self-sufficient containers.
4 #
5 # chkconfig:    345 20 80
6 #
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. \
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.
22 if is_yes "${NETWORKING}"; then
23         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
24                 msg_network_down "Docker"
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31 DOCKER_LOGFILE=/var/log/docker.log
32
33 # Get service config - may override defaults
34 [ -f /etc/sysconfig/docker ] && . /etc/sysconfig/docker
35
36 pidfile="/var/run/docker.pid"
37
38 start() {
39         # Check if the service is already running?
40         if [ -f /var/lock/subsys/docker ]; then
41                 msg_already_running "Docker"
42                 return
43         fi
44
45         # NOTE: docker daemon actually doesn't go to background, need to do that ourselves
46         # https://github.com/docker/docker/issues/2758
47
48         msg_starting "Docker"
49
50         export DOCKER_LOGFILE
51         daemon \
52                 --fork --pidfile $pidfile --waitfortime 60 \
53                 /usr/lib/docker daemon $OPTIONS
54
55         RETVAL=$?
56         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/docker
57 }
58
59 stop() {
60         if [ ! -f /var/lock/subsys/docker ]; then
61                 msg_not_running "Docker"
62                 return
63         fi
64
65         # Stop daemons.
66         msg_stopping "Docker"
67         killproc --pidfile $pidfile docker
68         rm -f /var/lock/subsys/docker
69 }
70
71 condrestart() {
72         if [ ! -f /var/lock/subsys/docker ]; then
73                 msg_not_running "Docker"
74                 RETVAL=$1
75                 return
76         fi
77
78         stop
79         start
80 }
81
82 RETVAL=0
83 # See how we were called.
84 case "$1" in
85   start)
86         start
87         ;;
88   stop)
89         stop
90         ;;
91   restart)
92         stop
93         start
94         ;;
95   try-restart)
96         condrestart 0
97         ;;
98   force-reload)
99         condrestart 7
100         ;;
101   status)
102         status --pidfile $pidfile docker docker
103         RETVAL=$?
104         ;;
105   *)
106         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
107         exit 3
108 esac
109
110 exit $RETVAL
This page took 0.074223 seconds and 3 git commands to generate.