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