github.com/a4a881d4/docker@v1.9.0-rc2/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 You configure the `docker` daemon in the `/etc/default/docker` file on your 89 system. You do this by specifying values in a `DOCKER_OPTS` variable. 90 91 To configure Docker options: 92 93 1. Log into your host as a user with `sudo` or `root` privileges. 94 95 2. If you don't have one, create the `/etc/default/docker` file on your host. Depending on how 96 you installed Docker, you may already have this file. 97 98 3. Open the file with your favorite editor. 99 100 ``` 101 $ sudo vi /etc/default/docker 102 ``` 103 104 4. Add a `DOCKER_OPTS` variable with the following options. These options are appended to the 105 `docker` daemon's run command. 106 107 ``` 108 DOCKER_OPTS="-D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376" 109 ``` 110 111 These options : 112 113 - Enable `-D` (debug) mode 114 - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively 115 - Listen for connections on `tcp://192.168.59.3:2376` 116 117 The command line reference has the [complete list of daemon flags](../reference/commandline/daemon.md) 118 with explanations. 119 120 121 5. Save and close the file. 122 123 6. Restart the `docker` daemon. 124 125 ``` 126 $ sudo restart docker 127 ``` 128 129 7. Verify that the `docker` daemon is running as specified with the `ps` command. 130 131 ``` 132 $ ps aux | grep docker | grep -v grep 133 ``` 134 135 ### Logs 136 137 By default logs for Upstart jobs are located in `/var/log/upstart` and the logs for `docker` daemon 138 can be located at `/var/log/upstart/docker.log` 139 140 $ tail -f /var/log/upstart/docker.log 141 INFO[0000] Loading containers: done. 142 INFO[0000] docker daemon: 1.6.0 4749651; execdriver: native-0.2; graphdriver: aufs 143 INFO[0000] +job acceptconnections() 144 INFO[0000] -job acceptconnections() = OK (0) 145 INFO[0000] Daemon has completed initialization 146 147 148 ## CentOS / Red Hat Enterprise Linux / Fedora 149 150 As of `7.x`, CentOS and RHEL use `systemd` as the process manager. As of `21`, Fedora uses 151 `systemd` as its process manager. 152 153 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: 154 155 $ sudo systemctl status docker 156 157 ### Running Docker 158 159 You can start/stop/restart the `docker` daemon using 160 161 $ sudo systemctl start docker 162 163 $ sudo systemctl stop docker 164 165 $ sudo systemctl restart docker 166 167 If you want Docker to start at boot, you should also: 168 169 $ sudo systemctl enable docker 170 171 ### Configuring Docker 172 173 You configure the `docker` daemon in the `/etc/sysconfig/docker` file on your 174 host. You do this by specifying values in a variable. For CentOS 7.x and RHEL 7.x, the name 175 of the variable is `OPTIONS` and for CentOS 6.x and RHEL 6.x, the name of the variable is 176 `other_args`. For this section, we will use CentOS 7.x as an example to configure the `docker` 177 daemon. 178 179 By default, systemd services are located either in `/etc/systemd/service`, `/lib/systemd/system` 180 or `/usr/lib/systemd/system`. The `docker.service` file can be found in either of these three 181 directories depending on your host. 182 183 To configure Docker options: 184 185 1. Log into your host as a user with `sudo` or `root` privileges. 186 187 2. If you don't have one, create the `/etc/sysconfig/docker` file on your host. Depending on how 188 you installed Docker, you may already have this file. 189 190 3. Open the file with your favorite editor. 191 192 ``` 193 $ sudo vi /etc/sysconfig/docker 194 ``` 195 196 4. Add a `OPTIONS` variable with the following options. These options are appended to the 197 command that starts the `docker` daemon. 198 199 ``` 200 OPTIONS="-D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376" 201 ``` 202 203 These options : 204 205 - Enable `-D` (debug) mode 206 - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively 207 - Listen for connections on `tcp://192.168.59.3:2376` 208 209 The command line reference has the [complete list of daemon flags](../reference/commandline/daemon.md) 210 with explanations. 211 212 5. Save and close the file. 213 214 6. Restart the `docker` daemon. 215 216 ``` 217 $ sudo systemctl restart docker 218 ``` 219 220 7. Verify that the `docker` daemon is running as specified with the `ps` command. 221 222 ``` 223 $ ps aux | grep docker | grep -v grep 224 ``` 225 226 ### Logs 227 228 systemd has its own logging system called the journal. The logs for the `docker` daemon can 229 be viewed using `journalctl -u docker` 230 231 $ sudo journalctl -u docker 232 May 06 00:22:05 localhost.localdomain systemd[1]: Starting Docker Application Container Engine... 233 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)" 234 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)" 235 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job init_networkdriver()" 236 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job init_networkdriver() = OK (0)" 237 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: start." 238 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: done." 239 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" 240 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job acceptconnections()" 241 May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job acceptconnections() = OK (0)" 242 243 _Note: Using and configuring journal is an advanced topic and is beyond the scope of this article._