]> git.pld-linux.org Git - packages/docker-ce.git/blame_incremental - docker.init
up to 19.03.0
[packages/docker-ce.git] / docker.init
... / ...
CommitLineData
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.
22if 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
27else
28 exit 0
29fi
30
31DOCKER_LOGFILE=/var/log/docker.log
32
33# Get service config - may override defaults
34[ -f /etc/sysconfig/docker ] && . /etc/sysconfig/docker
35
36pidfile="/var/run/docker.pid"
37
38start() {
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 touch "$DOCKER_LOGFILE"
51 chgrp docker "$DOCKER_LOGFILE"
52
53 export DOCKER_LOGFILE
54 daemon \
55 --fork --pidfile $pidfile --waitfortime 60 \
56 /usr/lib/dockerd $OPTIONS
57
58 RETVAL=$?
59 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/docker
60}
61
62stop() {
63 if [ ! -f /var/lock/subsys/docker ]; then
64 msg_not_running "Docker"
65 return
66 fi
67
68 # Stop daemons.
69 msg_stopping "Docker"
70 killproc --pidfile $pidfile docker
71 rm -f /var/lock/subsys/docker
72}
73
74condrestart() {
75 if [ ! -f /var/lock/subsys/docker ]; then
76 msg_not_running "Docker"
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)
105 status --pidfile $pidfile docker docker
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.143674 seconds and 4 git commands to generate.