瀏覽代碼

Merge pull request #9347 from SvenDowideit/extract-systemd-docs

Extract the systemd docs from various places and add a little more
Fred Lifton 10 年之前
父節點
當前提交
6a4d4fb2f5

+ 1 - 0
docs/mkdocs.yml

@@ -98,6 +98,7 @@ pages:
 - ['articles/ambassador_pattern_linking.md', 'Articles', 'Cross-Host linking using ambassador containers']
 - ['articles/runmetrics.md', 'Articles', 'Runtime metrics']
 - ['articles/b2d_volume_resize.md', 'Articles', 'Increasing a Boot2Docker volume']
+- ['articles/systemd.md', 'Articles', 'Controlling and configuring Docker using Systemd']
 
 # Reference
 - ['reference/index.md', '**HIDDEN**']

+ 101 - 0
docs/sources/articles/systemd.md

@@ -0,0 +1,101 @@
+page_title: Controlling and configuring Docker using Systemd
+page_description: Controlling and configuring Docker using Systemd
+page_keywords: docker, daemon, systemd, configuration
+
+# Controlling and configuring Docker using Systemd
+
+Many Linux distributions use systemd to start the Docker daemon. This document
+shows a few examples of how to customise Docker's settings.
+
+## Starting the Docker daemon
+
+Once Docker is installed, you will need to start the Docker daemon.
+
+    $ sudo systemctl start docker
+    # or on older distributions, you may need to use
+    $ sudo service docker start
+
+If you want Docker to start at boot, you should also:
+
+    $ sudo systemctl enable docker
+    # or on older distributions, you may need to use
+    $ sudo chkconfig docker on
+
+## Custom Docker daemon options
+
+There are a number of ways to configure the daemon flags and environment variables
+for your Docker daemon. 
+
+If the `docker.service` file is set to use an `EnvironmentFile`
+(often pointing to `/etc/sysconfig/docker`) then you can modify the
+referenced file.
+
+Or, you may need to edit the `docker.service` file, which can be in `/usr/lib/systemd/system`
+or `/etc/systemd/service`.
+
+### Runtime directory and storage driver
+
+You may want to control the disk space used for Docker images, containers
+and volumes by moving it to a separate partition.
+
+In this example, we'll assume that your `docker.services` file looks something like:
+
+    [Unit]
+    Description=Docker Application Container Engine
+    Documentation=http://docs.docker.com
+    After=network.target docker.socket
+    Requires=docker.socket
+    
+    [Service]
+    Type=notify
+    EnvironmentFile=-/etc/sysconfig/docker
+    ExecStart=/usr/bin/docker -d -H fd:// $OPTIONS
+    LimitNOFILE=1048576
+    LimitNPROC=1048576
+    
+    [Install]
+    Also=docker.socket
+
+This will allow us to add extra flags to the `/etc/sysconfig/docker` file by
+setting `OPTIONS`:
+
+    OPTIONS="--graph /mnt/docker-data --storage btrfs"
+
+You can also set other environment variables in this file, for example, the
+`HTTP_PROXY` environment variables described below.
+
+### HTTP Proxy
+
+This example overrides the default `docker.service` file.
+
+If you are behind a HTTP proxy server, for example in corporate settings, 
+you will need to add this configuration in the Docker systemd service file.
+
+Copy file `/usr/lib/systemd/system/docker.service` to `/etc/systemd/system/docker/service`.
+
+Add the following to the `[Service]` section in the new file:
+
+    Environment="HTTP_PROXY=http://proxy.example.com:80/"
+
+If you have internal Docker registries that you need to contact without
+proxying you can specify them via the `NO_PROXY` environment variable:
+
+    Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
+
+Flush changes:
+
+    $ sudo systemctl daemon-reload
+    
+Restart Docker:
+
+    $ sudo systemctl restart docker
+
+## Manually creating the systemd unit files
+
+When installing the binary without a package, you may want
+to integrate Docker with systemd. For this, simply install the two unit files
+(service and socket) from [the github
+repository](https://github.com/docker/docker/tree/master/contrib/init/systemd)
+to `/etc/systemd/system`.
+
+

+ 6 - 0
docs/sources/installation/archlinux.md

@@ -53,3 +53,9 @@ service:
 To start on system boot:
 
     $ sudo systemctl enable docker
+
+## Custom daemon options
+
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).

+ 10 - 4
docs/sources/installation/centos.md

@@ -45,11 +45,11 @@ to `/etc/systemd/system`.
 CentOS-7 introduced firewalld, which is a wrapper around iptables and can
 conflict with Docker.
 
-When firewalld is started or restarted it will remove the `DOCKER` chain
+When `firewalld` is started or restarted it will remove the `DOCKER` chain
 from iptables, preventing Docker from working properly.
 
-When using systemd, firewalld is started before Docker, but if you
-start or restart firewalld  after Docker, you will have to restart the Docker daemon.
+When using systemd, `firewalld` is started before Docker, but if you
+start or restart `firewalld` after Docker, you will have to restart the Docker daemon.
 
 ## Installing Docker - CentOS-6
 Please note that this for CentOS-6, this package is part of [Extra Packages
@@ -103,7 +103,13 @@ Run a simple bash shell to test the image:
     $ sudo docker run -i -t centos /bin/bash
 
 If everything is working properly, you'll get a simple bash prompt. Type
-exit to continue.
+`exit` to continue.
+
+## Custom daemon options
+
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
 
 ## Dockerfiles
 The CentOS Project provides a number of sample Dockerfiles which you may use

+ 4 - 21
docs/sources/installation/fedora.md

@@ -67,28 +67,11 @@ member of that group in order to contact the `docker -d` process.
 Adding users to the `docker` group is *not* necessary for Docker versions 1.0
 and above.
 
-## HTTP Proxy
+## Custom daemon options
 
-If you are behind a HTTP proxy server, for example in corporate settings, 
-you will need to add this configuration in the Docker *systemd service file*.
-
-Edit file `/usr/lib/systemd/system/docker.service`. Add the following to
-section `[Service]` :
-
-    Environment="HTTP_PROXY=http://proxy.example.com:80/"
-
-If you have internal Docker registries that you need to contact without
-proxying you can specify them via the `NO_PROXY` environment variable:
-
-    Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
-
-Flush changes:
-
-    $ systemctl daemon-reload
-    
-Restart Docker:
-
-    $ systemctl start docker
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
 
 ## What next?
 

+ 6 - 0
docs/sources/installation/frugalware.md

@@ -42,3 +42,9 @@ service:
 To start on system boot:
 
     $ sudo systemctl enable lxc-docker
+
+## Custom daemon options
+
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).

+ 4 - 0
docs/sources/installation/gentoolinux.md

@@ -91,3 +91,7 @@ To start the `docker` daemon:
 To start on system boot:
 
     $ sudo systemctl enable docker
+   
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).

+ 8 - 0
docs/sources/installation/openSUSE.md

@@ -71,5 +71,13 @@ hand to ensure the `FW_ROUTE` flag is set to `yes` like so:
 
 **Done!**
 
+## Custom daemon options
+
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
+
+## What's next
+
 Continue with the [User Guide](/userguide/).
 

+ 6 - 0
docs/sources/installation/oracle.md

@@ -75,6 +75,12 @@ and set `enabled=1` in the `[ol6_addons]` or the `[ol7_addons]` stanza.
 
 **Done!**
 
+## Custom daemon options
+
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
+
 ## Using the btrfs storage engine
 
 Docker on Oracle Linux 6 and 7 supports the use of the btrfs storage engine.

+ 7 - 0
docs/sources/installation/rhel.md

@@ -83,6 +83,13 @@ Now let's verify that Docker is working.
 
 Continue with the [User Guide](/userguide/).
 
+## Custom daemon options
+
+If you need to add an HTTP Proxy, set a different directory or partition for the
+Docker runtime files, or make other customizations, read our systemd article to
+learn how to [customize your systemd Docker daemon options](/articles/systemd/).
+
+
 ## Issues?
 
 If you have any issues - please report them directly in the