]> git.pld-linux.org Git - packages/docker.git/blame - docker.init
provide docker(engine) for docker-compose
[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
a990be6d
ER
31DOCKER_LOGFILE=/var/log/docker.log
32
345101bd 33# Get service config - may override defaults
47009a45 34[ -f /etc/sysconfig/docker ] && . /etc/sysconfig/docker
345101bd
ER
35
36pidfile="/var/run/docker.pid"
37
38start() {
39 # Check if the service is already running?
47009a45
ER
40 if [ -f /var/lock/subsys/docker ]; then
41 msg_already_running "Docker"
345101bd
ER
42 return
43 fi
44
c301aaa7
ER
45 # NOTE: docker daemon actually doesn't go to background, need to do that ourselves
46 # https://github.com/docker/docker/issues/2758
47
47009a45 48 msg_starting "Docker"
a990be6d 49
738e5f20
ER
50 touch "$DOCKER_LOGFILE"
51 chgrp docker "$DOCKER_LOGFILE"
52
a990be6d
ER
53 export DOCKER_LOGFILE
54 daemon \
55 --fork --pidfile $pidfile --waitfortime 60 \
29baba5b 56 /usr/lib/dockerd $OPTIONS
9bb76e88 57
345101bd 58 RETVAL=$?
47009a45 59 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/docker
345101bd
ER
60}
61
62stop() {
47009a45
ER
63 if [ ! -f /var/lock/subsys/docker ]; then
64 msg_not_running "Docker"
345101bd
ER
65 return
66 fi
67
68 # Stop daemons.
47009a45 69 msg_stopping "Docker"
b16e11f6 70 killproc --pidfile $pidfile docker
47009a45 71 rm -f /var/lock/subsys/docker
345101bd
ER
72}
73
74condrestart() {
47009a45
ER
75 if [ ! -f /var/lock/subsys/docker ]; then
76 msg_not_running "Docker"
345101bd
ER
77 RETVAL=$1
78 return
79 fi
80
81 stop
82 start
83}
84
85RETVAL=0
86# See how we were called.
87case "$1" in
88 start)
89 start
90 ;;
91 stop)
92 stop
93 ;;
94 restart)
95 stop
96 start
97 ;;
98 try-restart)
99 condrestart 0
100 ;;
101 force-reload)
102 condrestart 7
103 ;;
104 status)
47009a45 105 status --pidfile $pidfile docker docker
345101bd
ER
106 RETVAL=$?
107 ;;
108 *)
109 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
110 exit 3
111esac
112
113exit $RETVAL
This page took 0.04884 seconds and 4 git commands to generate.