From 8308f5eca65b36c1c1d5d22575ef93c09b58cb6c Mon Sep 17 00:00:00 2001 From: Misty Stanley-Jones Date: Tue, 25 Oct 2016 11:27:16 -0700 Subject: [PATCH] Formatting --- engine/admin/index.md | 214 +++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 106 deletions(-) diff --git a/engine/admin/index.md b/engine/admin/index.md index ef66f33278..60d6fab819 100644 --- a/engine/admin/index.md +++ b/engine/admin/index.md @@ -5,10 +5,6 @@ aliases: description: Configuring and running the Docker daemon on various distributions keywords: - docker, daemon, configuration, running, process managers -menu: - main: - parent: engine_admin - weight: 0 title: Configuring and running Docker --- @@ -27,13 +23,15 @@ or `systemd` to manage the `docker` daemon's start and stop. The Docker daemon can be run directly using the `dockerd` command. By default it listens on the Unix socket `unix:///var/run/docker.sock` - $ dockerd +```bash +$ dockerd - INFO[0000] +job init_networkdriver() - INFO[0000] +job serveapi(unix:///var/run/docker.sock) - INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) - ... - ... +INFO[0000] +job init_networkdriver() +INFO[0000] +job serveapi(unix:///var/run/docker.sock) +INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) +... +... +``` ### Configuring the docker daemon directly @@ -45,14 +43,15 @@ Some of the daemon's options are: | Flag | Description | |-----------------------|-----------------------------------------------------------| -| `-D`, `--debug=false` | Enable or disable debug mode. By default, this is false. | +| `-D`, `--debug=false` | Enable or disable debug mode. By default, this is false. | | `-H`,`--host=[]` | Daemon socket(s) to connect to. | | `--tls=false` | Enable or disable TLS. By default, this is false. | Here is an example of running the Docker daemon with configuration options: - - $ dockerd -D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376 +```bash +$ dockerd -D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376 +``` These options : @@ -74,8 +73,8 @@ command on Linux systems. For example, `kill -USR1 ` sends the `SIGU signal to the daemon process, causing the stack dump to be added to the daemon log. > **Note:** The log level setting of the daemon must be at least "info" level and above for -> the stack trace to be saved to the logfile. By default the daemon's log level is set to -> "info". +the stack trace to be saved to the logfile. By default the daemon's log level is set to +"info". The daemon will continue operating after handling the `SIGUSR1` signal and dumping the stack traces to the log. The stack traces can be used to determine the state of all goroutines and @@ -88,21 +87,21 @@ are located in `/etc/init` and the `docker` Upstart job can be found at `/etc/i After successfully [installing Docker for Ubuntu](../installation/linux/ubuntulinux.md), you can check the running status using Upstart in this way: +```bash +$ sudo status docker - $ sudo status docker - - docker start/running, process 989 - +docker start/running, process 989 +``` ### Running Docker You can start/stop/restart the `docker` daemon using +```bash +$ sudo start docker - $ sudo start docker - - $ sudo stop docker - - $ sudo restart docker +$ sudo stop docker +$ sudo restart docker +``` ### Configuring Docker @@ -120,40 +119,40 @@ To configure Docker options: 2. If you don't have one, create the `/etc/default/docker` file on your host. Depending on how you installed Docker, you may already have this file. -3. Open the file with your favorite editor. +3. Open the file with your favorite editor. - ``` + ```bash $ sudo vi /etc/default/docker ``` -4. Add a `DOCKER_OPTS` variable with the following options. These options are appended to the +4. Add a `DOCKER_OPTS` variable with the following options. These options are appended to the `docker` daemon's run command. -``` + ```bash DOCKER_OPTS="-D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376" -``` - -These options : - -- Enable `-D` (debug) mode -- Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively -- Listen for connections on `tcp://192.168.59.3:2376` - -The command line reference has the [complete list of daemon flags](../reference/commandline/dockerd.md) -with explanations. - - -5. Save and close the file. - -6. Restart the `docker` daemon. - ``` + + These options : + + - Enable `-D` (debug) mode + - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively + - Listen for connections on `tcp://192.168.59.3:2376` + + The command line reference has the [complete list of daemon flags](../reference/commandline/dockerd.md) + with explanations. + + +5. Save and close the file. + +6. Restart the `docker` daemon. + + ```bash $ sudo restart docker ``` 7. Verify that the `docker` daemon is running as specified with the `ps` command. - ``` + ```bash $ ps aux | grep docker | grep -v grep ``` @@ -162,13 +161,15 @@ with explanations. By default logs for Upstart jobs are located in `/var/log/upstart` and the logs for `docker` daemon can be located at `/var/log/upstart/docker.log` - $ tail -f /var/log/upstart/docker.log - INFO[0000] Loading containers: done. - INFO[0000] Docker daemon commit=1b09a95-unsupported graphdriver=aufs version=1.11.0-dev - INFO[0000] +job acceptconnections() - INFO[0000] -job acceptconnections() = OK (0) - INFO[0000] Daemon has completed initialization +```bash +$ tail -f /var/log/upstart/docker.log +INFO[0000] Loading containers: done. +INFO[0000] Docker daemon commit=1b09a95-unsupported graphdriver=aufs version=1.11.0-dev +INFO[0000] +job acceptconnections() +INFO[0000] -job acceptconnections() = OK (0) +INFO[0000] Daemon has completed initialization +``` ## CentOS / Red Hat Enterprise Linux / Fedora @@ -176,23 +177,23 @@ As of `7.x`, CentOS and RHEL use `systemd` as the process manager. As of `21`, F `systemd` as its process manager. 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: - - $ sudo systemctl status docker - +```bash +$ sudo systemctl status docker +``` ### Running Docker You can start/stop/restart the `docker` daemon using +```bash +$ sudo systemctl start docker - $ sudo systemctl start docker - - $ sudo systemctl stop docker - - $ sudo systemctl restart docker +$ sudo systemctl stop docker +$ sudo systemctl restart docker +``` If you want Docker to start at boot, you should also: - - $ sudo systemctl enable docker - +```bash +$ sudo systemctl enable docker +``` ### Configuring Docker For CentOS 7.x and RHEL 7.x you can [control and configure Docker with systemd](systemd.md). @@ -207,58 +208,58 @@ For this section, we will use CentOS 7.x as an example to configure the `docker` To configure Docker options: -1. Log into your host as a user with `sudo` or `root` privileges. +1. Log into your host as a user with `sudo` or `root` privileges. -2. Create the `/etc/systemd/system/docker.service.d` directory. +2. Create the `/etc/systemd/system/docker.service.d` directory. - ``` + ```bash $ sudo mkdir /etc/systemd/system/docker.service.d ``` -3. Create a `/etc/systemd/system/docker.service.d/docker.conf` file. +3. Create a `/etc/systemd/system/docker.service.d/docker.conf` file. -4. Open the file with your favorite editor. +4. Open the file with your favorite editor. - ``` + ```bash $ sudo vi /etc/systemd/system/docker.service.d/docker.conf ``` -5. Override the `ExecStart` configuration from your `docker.service` file to customize -the `docker` daemon. To modify the `ExecStart` configuration you have to specify -an empty configuration followed by a new one as follows: - -``` -[Service] -ExecStart= -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 -``` - -These options : - -- Enable `-D` (debug) mode -- Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively -- Listen for connections on `tcp://192.168.59.3:2376` - -The command line reference has the [complete list of daemon flags](../reference/commandline/dockerd.md) -with explanations. - -6. Save and close the file. - -7. Flush changes. +5. Override the `ExecStart` configuration from your `docker.service` file to customize + the `docker` daemon. To modify the `ExecStart` configuration you have to specify + an empty configuration followed by a new one as follows: + ```bash + [Service] + ExecStart= + 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 ``` + + These options : + + - Enable `-D` (debug) mode + - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively + - Listen for connections on `tcp://192.168.59.3:2376` + + The command line reference has the [complete list of daemon flags](../reference/commandline/dockerd.md) + with explanations. + +6. Save and close the file. + +7. Flush changes. + + ```bash $ sudo systemctl daemon-reload ``` -8. Restart the `docker` daemon. +8. Restart the `docker` daemon. - ``` + ```bash $ sudo systemctl restart docker ``` -9. Verify that the `docker` daemon is running as specified with the `ps` command. +9. Verify that the `docker` daemon is running as specified with the `ps` command. - ``` + ```bash $ ps aux | grep docker | grep -v grep ``` @@ -266,17 +267,18 @@ with explanations. systemd has its own logging system called the journal. The logs for the `docker` daemon can be viewed using `journalctl -u docker` - - $ sudo journalctl -u docker - May 06 00:22:05 localhost.localdomain systemd[1]: Starting Docker Application Container Engine... - 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)" - 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)" - May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job init_networkdriver()" - May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job init_networkdriver() = OK (0)" - May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: start." - May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: done." - 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" - May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job acceptconnections()" - May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job acceptconnections() = OK (0)" +```no-highlight +$ sudo journalctl -u docker +May 06 00:22:05 localhost.localdomain systemd[1]: Starting Docker Application Container Engine... +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)" +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)" +May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job init_networkdriver()" +May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job init_networkdriver() = OK (0)" +May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: start." +May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: done." +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" +May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job acceptconnections()" +May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job acceptconnections() = OK (0)" +``` _Note: Using and configuring journal is an advanced topic and is beyond the scope of this article._