github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/docs/admin/configuring.md (about)

     1  <!--[metadata]>
     2  +++
     3  aliases = ["/engine/articles/configuring/"]
     4  title = "Configuring and running Docker"
     5  description = "Configuring and running the Docker daemon on various distributions"
     6  keywords = ["docker, daemon, configuration, running,  process managers"]
     7  [menu.main]
     8  parent = "engine_admin"
     9  weight = 3
    10  +++
    11  <![end-metadata]-->
    12  
    13  # Configuring and running Docker on various distributions
    14  
    15  After successfully installing Docker, the `docker` daemon runs with its default
    16  configuration.
    17  
    18  In a production environment, system administrators typically configure the
    19  `docker` daemon to start and stop according to an organization's requirements. In most
    20  cases, the system administrator configures a process manager such as `SysVinit`, `Upstart`,
    21  or `systemd` to manage the `docker` daemon's start and stop.
    22  
    23  ### Running the docker daemon directly
    24  
    25  The `docker` daemon can be run directly using the `docker daemon` command. By default it listens on
    26  the Unix socket `unix:///var/run/docker.sock`
    27  
    28      $ docker daemon
    29  
    30      INFO[0000] +job init_networkdriver()
    31      INFO[0000] +job serveapi(unix:///var/run/docker.sock)
    32      INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
    33      ...
    34      ...
    35  
    36  ### Configuring the docker daemon directly
    37  
    38  If you're running the `docker` daemon directly by running `docker daemon` instead
    39  of using a process manager, you can append the configuration options to the `docker` run
    40  command directly. Other options can be passed to the `docker` 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 daemon -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/daemon.md)
    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/linux/ubuntulinux.md),
    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  The instructions below depict configuring Docker on a system that uses `upstart`
    90  as the process manager. As of Ubuntu 15.04, Ubuntu uses `systemd` as its process
    91  manager. For Ubuntu 15.04 and higher, refer to [control and configure Docker with systemd](systemd.md).
    92  
    93  You configure the `docker` daemon in the `/etc/default/docker` file on your
    94  system. You do this by specifying values in a `DOCKER_OPTS` variable.
    95  
    96  To configure Docker options:
    97  
    98  1. Log into your host as a user with `sudo` or `root` privileges.
    99  
   100  2. If you don't have one, create the `/etc/default/docker` file on your host. Depending on how
   101  you installed Docker, you may already have this file.
   102  
   103  3. Open the file with your favorite editor.
   104  
   105      ```
   106      $ sudo vi /etc/default/docker
   107      ```
   108  
   109  4. Add a `DOCKER_OPTS` variable with the following options. These options are appended to the
   110  `docker` daemon's run command.
   111  
   112  ```
   113      DOCKER_OPTS="-D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376"
   114  ```
   115  
   116  These options :
   117  
   118  - Enable `-D` (debug) mode
   119  - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively
   120  - Listen for connections on `tcp://192.168.59.3:2376`
   121  
   122  The command line reference has the [complete list of daemon flags](../reference/commandline/daemon.md)
   123  with explanations.
   124  
   125  
   126  5. Save and close the file.
   127  
   128  6. Restart the `docker` daemon.
   129  
   130      ```
   131      $ sudo restart docker
   132      ```
   133  
   134  7. Verify that the `docker` daemon is running as specified with the `ps` command.
   135  
   136      ```
   137      $ ps aux | grep docker | grep -v grep
   138      ```
   139  
   140  ### Logs
   141  
   142  By default logs for Upstart jobs are located in `/var/log/upstart` and the logs for `docker` daemon
   143  can be located at `/var/log/upstart/docker.log`
   144  
   145      $ tail -f /var/log/upstart/docker.log
   146      INFO[0000] Loading containers: done.
   147      INFO[0000] docker daemon: 1.6.0 4749651; execdriver: native-0.2; graphdriver: aufs
   148      INFO[0000] +job acceptconnections()
   149      INFO[0000] -job acceptconnections() = OK (0)
   150      INFO[0000] Daemon has completed initialization
   151  
   152  
   153  ## CentOS / Red Hat Enterprise Linux / Fedora
   154  
   155  As of `7.x`, CentOS and RHEL use `systemd` as the process manager. As of `21`, Fedora uses
   156  `systemd` as its process manager.
   157  
   158  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:
   159  
   160      $ sudo systemctl status docker
   161  
   162  ### Running Docker
   163  
   164  You can start/stop/restart the `docker` daemon using
   165  
   166      $ sudo systemctl start docker
   167  
   168      $ sudo systemctl stop docker
   169  
   170      $ sudo systemctl restart docker
   171  
   172  If you want Docker to start at boot, you should also:
   173  
   174      $ sudo systemctl enable docker
   175  
   176  ### Configuring Docker
   177  
   178  For CentOS 7.x and RHEL 7.x you can [control and configure Docker with systemd](systemd.md).
   179  
   180  Previously, for CentOS 6.x and RHEL 6.x you would configure the `docker` daemon in
   181  the `/etc/sysconfig/docker` file on your system. You would do this by specifying
   182  values in a `other_args` variable. For a short time in CentOS 7.x and RHEL 7.x you
   183  would specify values in a `OPTIONS` variable. This is no longer recommended in favor
   184  of using systemd directly.
   185  
   186  For this section, we will use CentOS 7.x as an example to configure the `docker` daemon.
   187  
   188  To configure Docker options:
   189  
   190  1. Log into your host as a user with `sudo` or `root` privileges.
   191  
   192  2. Create the `/etc/systemd/system/docker.service.d` directory.
   193  
   194      ```
   195      $ sudo mkdir /etc/systemd/system/docker.service.d
   196      ```
   197  
   198  3. Create a  `/etc/systemd/system/docker.service.d/docker.conf` file.
   199  
   200  4. Open the file with your favorite editor.
   201  
   202      ```
   203      $ sudo vi /etc/systemd/system/docker.service.d/docker.conf
   204      ```
   205  
   206  5. Override the `ExecStart` configuration from your `docker.service` file to customize
   207  the `docker` daemon. To modify the `ExecStart` configuration you have to specify
   208  an empty configuration followed by a new one as follows:
   209  
   210  ```
   211  [Service]
   212  ExecStart=
   213  ExecStart=/usr/bin/docker daemon -H fd:// -D --tls=true --tlscert=/var/docker/server.pem --tlskey=/var/docker/serverkey.pem -H tcp://192.168.59.3:2376
   214  ```
   215  
   216  These options :
   217  
   218  - Enable `-D` (debug) mode
   219  - Set `tls` to true with the server certificate and key specified using `--tlscert` and `--tlskey` respectively
   220  - Listen for connections on `tcp://192.168.59.3:2376`
   221  
   222  The command line reference has the [complete list of daemon flags](../reference/commandline/daemon.md)
   223  with explanations.
   224  
   225  6. Save and close the file.
   226  
   227  7. Flush changes.
   228  
   229      ```
   230      $ sudo systemctl daemon-reload
   231      ```
   232  
   233  8. Restart the `docker` daemon.
   234  
   235      ```
   236      $ sudo systemctl restart docker
   237      ```
   238  
   239  9. Verify that the `docker` daemon is running as specified with the `ps` command.
   240  
   241      ```
   242      $ ps aux | grep docker | grep -v grep
   243      ```
   244  
   245  ### Logs
   246  
   247  systemd has its own logging system called the journal. The logs for the `docker` daemon can
   248  be viewed using `journalctl -u docker`
   249  
   250      $ sudo journalctl -u docker
   251      May 06 00:22:05 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
   252      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)"
   253      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)"
   254      May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job init_networkdriver()"
   255      May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job init_networkdriver() = OK (0)"
   256      May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: start."
   257      May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="Loading containers: done."
   258      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"
   259      May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="+job acceptconnections()"
   260      May 06 00:22:06 localhost.localdomain docker[2495]: time="2015-05-06T00:22:06Z" level="info" msg="-job acceptconnections() = OK (0)"
   261  
   262  _Note: Using and configuring journal is an advanced topic and is beyond the scope of this article._