github.com/vincentwoo/docker@v0.7.3-0.20160116130405-82401a4b13c0/docs/articles/configuring.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Configuring and running Docker" 4 description = "Configuring and running the Docker daemon on various distributions" 5 keywords = ["docker, daemon, configuration, running, process managers"] 6 [menu.main] 7 parent = "smn_administrate" 8 weight = 3 9 +++ 10 <![end-metadata]--> 11 12 # Configuring and running Docker on various distributions 13 14 After successfully installing Docker, the `docker` daemon runs with its default 15 configuration. 16 17 In a production environment, system administrators typically configure the 18 `docker` daemon to start and stop according to an organization's requirements. In most 19 cases, the system administrator configures a process manager such as `SysVinit`, `Upstart`, 20 or `systemd` to manage the `docker` daemon's start and stop. 21 22 ### Running the docker daemon directly 23 24 The `docker` daemon can be run directly using the `docker daemon` command. By default it listens on 25 the Unix socket `unix:///var/run/docker.sock` 26 27 $ docker daemon 28 29 INFO[0000] +job init_networkdriver() 30 INFO[0000] +job serveapi(unix:///var/run/docker.sock) 31 INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) 32 ... 33 ... 34 35 ### Configuring the docker daemon directly 36 37 If you're running the `docker` daemon directly by running `docker daemon` instead 38 of using a process manager, you can append the configuration options to the `docker` run 39 command directly. Other options can be passed to the `docker` daemon to configure it. 40 41 Some of the daemon's options are: 42 43 | Flag | Description | 44 |-----------------------|-----------------------------------------------------------| 45 | `-D`, `--debug=false` | Enable or disable debug mode. By default, this is false. | 46 | `-H`,`--host=[]` | Daemon socket(s) to connect to. | 47 | `--tls=false` | Enable or disable TLS. By default, this is false. | 48 49 50 Here is a an example of running the `docker` daemon with configuration options: 51 52 $ docker daemon -D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376 53 54 These options : 55 56 - Enable `-D` (debug) mode 57 - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively 58 - Listen for connections on `tcp://192.168.59.3:2376` 59 60 The command line reference has the [complete list of daemon flags](../reference/commandline/daemon.md) 61 with explanations. 62 63 ## Ubuntu 64 65 As of `14.04`, Ubuntu uses Upstart as a process manager. By default, Upstart jobs 66 are located in `/etc/init` and the `docker` Upstart job can be found at `/etc/init/docker.conf`. 67 68 After successfully [installing Docker for Ubuntu](../installation/ubuntulinux.md), 69 you can check the running status using Upstart in this way: 70 71 $ sudo status docker 72 73 docker start/running, process 989 74 75 ### Running Docker 76 77 You can start/stop/restart the `docker` daemon using 78 79 $ sudo start docker 80 81 $ sudo stop docker 82 83 $ sudo restart docker 84 85 86 ### Configuring Docker 87 88 The instructions below depict configuring Docker on a system that uses `upstart` 89 as the process manager. As of Ubuntu 15.04, Ubuntu uses `systemd` as its process 90 manager. For Ubuntu 15.04 and higher, refer to [control and configure Docker with systemd](systemd.md). 91 92 You configure the `docker` daemon in the `/etc/default/docker` file on your 93 system. You do this by specifying values in a `DOCKER_OPTS` variable. 94 95 To configure Docker options: 96 97 1. Log into your host as a user with `sudo` or `root` privileges. 98 99 2. If you don't have one, create the `/etc/default/docker` file on your host. Depending on how 100 you installed Docker, you may already have this file. 101 102 3. Open the file with your favorite editor. 103 104 ``` 105 $ sudo vi /etc/default/docker 106 ``` 107 108 4. Add a `DOCKER_OPTS` variable with the following options. These options are appended to the 109 `docker` daemon's run command. 110 111 ``` 112 DOCKER_OPTS="-D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376" 113 ``` 114 115 These options : 116 117 - Enable `-D` (debug) mode 118 - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively 119 - Listen for connections on `tcp://192.168.59.3:2376` 120 121 The command line reference has the [complete list of daemon flags](../reference/commandline/daemon.md) 122 with explanations. 123 124 125 5. Save and close the file. 126 127 6. Restart the `docker` daemon. 128 129 ``` 130 $ sudo restart docker 131 ``` 132 133 7. Verify that the `docker` daemon is running as specified with the `ps` command. 134 135 ``` 136 $ ps aux | grep docker | grep -v grep 137 ``` 138 139 ### Logs 140 141 By default logs for Upstart jobs are located in `/var/log/upstart` and the logs for `docker` daemon 142 can be located at `/var/log/upstart/docker.log` 143 144 $ tail -f /var/log/upstart/docker.log 145 INFO[0000] Loading containers: done. 146 INFO[0000] docker daemon: 1.6.0 4749651; execdriver: native-0.2; graphdriver: aufs 147 INFO[0000] +job acceptconnections() 148 INFO[0000] -job acceptconnections() = OK (0) 149 INFO[0000] Daemon has completed initialization 150 151 152 ## CentOS / Red Hat Enterprise Linux / Fedora 153 154 As of `7.x`, CentOS and RHEL use `systemd` as the process manager. As of `21`, Fedora uses 155 `systemd` as its process manager. 156 157 After successfully installing Docker for [CentOS](../installation/centos.md)/[Red Hat Enterprise Linux](../installation/rhel.md)/[Fedora](../installation/fedora.md), you can check the running status in this way: 158 159 $ sudo systemctl status docker 160 161 ### Running Docker 162 163 You can start/stop/restart the `docker` daemon using 164 165 $ sudo systemctl start docker 166 167 $ sudo systemctl stop docker 168 169 $ sudo systemctl restart docker 170 171 If you want Docker to start at boot, you should also: 172 173 $ sudo systemctl enable docker 174 175 ### Configuring Docker 176 177 For CentOS 7.x and RHEL 7.x you can [control and configure Docker with systemd](systemd.md). 178 179 Previously, for CentOS 6.x and RHEL 6.x you would configure the `docker` daemon in 180 the `/etc/sysconfig/docker` file on your system. You would do this by specifying 181 values in a `other_args` variable. For a short time in CentOS 7.x and RHEL 7.x you 182 would specify values in a `OPTIONS` variable. This is no longer recommended in favor 183 of using systemd directly. 184 185 For this section, we will use CentOS 7.x as an example to configure the `docker` daemon. 186 187 To configure Docker options: 188 189 1. Log into your host as a user with `sudo` or `root` privileges. 190 191 2. Create the `/etc/systemd/system/docker.service.d` directory. 192 193 ``` 194 $ sudo mkdir /etc/systemd/system/docker.service.d 195 ``` 196 197 3. Create a `/etc/systemd/system/docker.service.d/docker.conf` file. 198 199 4. Open the file with your favorite editor. 200 201 ``` 202 $ sudo vi /etc/systemd/system/docker.service.d/docker.conf 203 ``` 204 205 5. Override the `ExecStart` configuration from your `docker.service` file to customize 206 the `docker` daemon. To modify the `ExecStart` configuration you have to specify 207 an empty configuration followed by a new one as follows: 208 209 ``` 210 [Service] 211 ExecStart= 212 ExecStart=/usr/bin/docker daemon -H fd:// -D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376 213 ``` 214 215 These options : 216 217 - Enable `-D` (debug) mode 218 - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively 219 - Listen for connections on `tcp://192.168.59.3:2376` 220 221 The command line reference has the [complete list of daemon flags](../reference/commandline/daemon.md) 222 with explanations. 223 224 6. Save and close the file. 225 226 7. Flush changes. 227 228 ``` 229 $ sudo systemctl daemon-reload 230 ``` 231 232 8. Restart the `docker` daemon. 233 234 ``` 235 $ sudo systemctl restart docker 236 ``` 237 238 9. Verify that the `docker` daemon is running as specified with the `ps` command. 239 240 ``` 241 $ ps aux | grep docker | grep -v grep 242 ``` 243 244 ### Logs 245 246 systemd has its own logging system called the journal. The logs for the `docker` daemon can 247 be viewed using `journalctl -u docker` 248 249 $ sudo journalctl -u docker 250 May 06 00:22:05 localhost.localdomain systemd[1]: Starting Docker Application Container Engine... 251 May 06 00:22:05 localhost.localdomain docker[2495]: time="2015-05-06T00:22:05Z" level="info" msg="+job serveapi(unix:///var/run/docker.sock)" 252 May 06 00:22:05 localhost.localdomain docker[2495]: time="2015-05-06T00:22:05Z" level="info" msg="Listening for HTTP on unix (/var/run/docker.sock)" 253 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job init_networkdriver()" 254 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job init_networkdriver() = OK (0)" 255 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: start." 256 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: done." 257 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="docker daemon: 1.5.0-dev fc0329b/1.5.0; execdriver: native-0.2; graphdriver: devicemapper" 258 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job acceptconnections()" 259 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job acceptconnections() = OK (0)" 260 261 _Note: Using and configuring journal is an advanced topic and is beyond the scope of this article._