mirror of https://github.com/docker/docs.git
Merge pull request #9347 from SvenDowideit/extract-systemd-docs
Extract the systemd docs from various places and add a little more
This commit is contained in:
commit
6a4d4fb2f5
|
@ -98,6 +98,7 @@ pages:
|
||||||
- ['articles/ambassador_pattern_linking.md', 'Articles', 'Cross-Host linking using ambassador containers']
|
- ['articles/ambassador_pattern_linking.md', 'Articles', 'Cross-Host linking using ambassador containers']
|
||||||
- ['articles/runmetrics.md', 'Articles', 'Runtime metrics']
|
- ['articles/runmetrics.md', 'Articles', 'Runtime metrics']
|
||||||
- ['articles/b2d_volume_resize.md', 'Articles', 'Increasing a Boot2Docker volume']
|
- ['articles/b2d_volume_resize.md', 'Articles', 'Increasing a Boot2Docker volume']
|
||||||
|
- ['articles/systemd.md', 'Articles', 'Controlling and configuring Docker using Systemd']
|
||||||
|
|
||||||
# Reference
|
# Reference
|
||||||
- ['reference/index.md', '**HIDDEN**']
|
- ['reference/index.md', '**HIDDEN**']
|
||||||
|
|
|
@ -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`.
|
||||||
|
|
||||||
|
|
|
@ -53,3 +53,9 @@ service:
|
||||||
To start on system boot:
|
To start on system boot:
|
||||||
|
|
||||||
$ sudo systemctl enable docker
|
$ 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/).
|
||||||
|
|
|
@ -45,11 +45,11 @@ to `/etc/systemd/system`.
|
||||||
CentOS-7 introduced firewalld, which is a wrapper around iptables and can
|
CentOS-7 introduced firewalld, which is a wrapper around iptables and can
|
||||||
conflict with Docker.
|
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.
|
from iptables, preventing Docker from working properly.
|
||||||
|
|
||||||
When using systemd, firewalld is started before Docker, but if you
|
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.
|
start or restart `firewalld` after Docker, you will have to restart the Docker daemon.
|
||||||
|
|
||||||
## Installing Docker - CentOS-6
|
## Installing Docker - CentOS-6
|
||||||
Please note that this for CentOS-6, this package is part of [Extra Packages
|
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
|
$ sudo docker run -i -t centos /bin/bash
|
||||||
|
|
||||||
If everything is working properly, you'll get a simple bash prompt. Type
|
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
|
## Dockerfiles
|
||||||
The CentOS Project provides a number of sample Dockerfiles which you may use
|
The CentOS Project provides a number of sample Dockerfiles which you may use
|
||||||
|
|
|
@ -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
|
Adding users to the `docker` group is *not* necessary for Docker versions 1.0
|
||||||
and above.
|
and above.
|
||||||
|
|
||||||
## HTTP Proxy
|
## Custom daemon options
|
||||||
|
|
||||||
If you are behind a HTTP proxy server, for example in corporate settings,
|
If you need to add an HTTP Proxy, set a different directory or partition for the
|
||||||
you will need to add this configuration in the Docker *systemd service file*.
|
Docker runtime files, or make other customizations, read our systemd article to
|
||||||
|
learn how to [customize your systemd Docker daemon options](/articles/systemd/).
|
||||||
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
|
|
||||||
|
|
||||||
## What next?
|
## What next?
|
||||||
|
|
||||||
|
|
|
@ -42,3 +42,9 @@ service:
|
||||||
To start on system boot:
|
To start on system boot:
|
||||||
|
|
||||||
$ sudo systemctl enable lxc-docker
|
$ 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/).
|
||||||
|
|
|
@ -91,3 +91,7 @@ To start the `docker` daemon:
|
||||||
To start on system boot:
|
To start on system boot:
|
||||||
|
|
||||||
$ sudo systemctl enable docker
|
$ 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/).
|
||||||
|
|
|
@ -71,5 +71,13 @@ hand to ensure the `FW_ROUTE` flag is set to `yes` like so:
|
||||||
|
|
||||||
**Done!**
|
**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/).
|
Continue with the [User Guide](/userguide/).
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,12 @@ and set `enabled=1` in the `[ol6_addons]` or the `[ol7_addons]` stanza.
|
||||||
|
|
||||||
**Done!**
|
**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
|
## Using the btrfs storage engine
|
||||||
|
|
||||||
Docker on Oracle Linux 6 and 7 supports the use of the btrfs storage engine.
|
Docker on Oracle Linux 6 and 7 supports the use of the btrfs storage engine.
|
||||||
|
|
|
@ -83,6 +83,13 @@ Now let's verify that Docker is working.
|
||||||
|
|
||||||
Continue with the [User Guide](/userguide/).
|
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?
|
## Issues?
|
||||||
|
|
||||||
If you have any issues - please report them directly in the
|
If you have any issues - please report them directly in the
|
||||||
|
|
Loading…
Reference in New Issue