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