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