2015-06-07 23:07:20 -04:00
|
|
|
<!--[metadata]>
|
|
|
|
+++
|
2016-01-23 23:36:40 -05:00
|
|
|
aliases = [ "/engine/installation/ubuntulinux/"]
|
2015-06-07 23:07:20 -04:00
|
|
|
title = "Installation on Ubuntu "
|
|
|
|
description = "Instructions for installing Docker on Ubuntu. "
|
2015-09-28 17:01:52 -04:00
|
|
|
keywords = ["Docker, Docker documentation, requirements, apt, installation, ubuntu"]
|
2015-06-07 23:07:20 -04:00
|
|
|
[menu.main]
|
2016-01-23 23:36:40 -05:00
|
|
|
parent = "engine_linux"
|
2015-09-28 17:01:52 -04:00
|
|
|
weight = -6
|
2015-06-07 23:07:20 -04:00
|
|
|
+++
|
|
|
|
<![end-metadata]-->
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-06-16 09:04:13 -04:00
|
|
|
# Ubuntu
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
Docker is supported on these Ubuntu operating systems:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
- Ubuntu Wily 15.10
|
2015-07-27 13:55:26 -04:00
|
|
|
- Ubuntu Trusty 14.04 (LTS)
|
|
|
|
- Ubuntu Precise 12.04 (LTS)
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
This page instructs you to install using Docker-managed release packages and
|
|
|
|
installation mechanisms. Using these packages ensures you get the latest release
|
|
|
|
of Docker. If you wish to install using Ubuntu-managed packages, consult your
|
|
|
|
Ubuntu documentation.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
>**Note**: Ubuntu Utopic 14.10 and 15.04 exist in Docker's `APT` repository but
|
2015-12-20 10:00:53 -05:00
|
|
|
> are no longer officially supported.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
2015-06-23 08:14:53 -04:00
|
|
|
## Prerequisites
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
Docker requires a 64-bit installation regardless of your Ubuntu version.
|
|
|
|
Additionally, your kernel must be 3.10 at minimum. The latest 3.10 minor version
|
|
|
|
or a newer maintained version are also acceptable.
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
Kernels older than 3.10 lack some of the features required to run Docker
|
|
|
|
containers. These older versions are known to have bugs which cause data loss
|
|
|
|
and frequently panic under certain conditions.
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
To check your current kernel version, open a terminal and use `uname -r` to
|
|
|
|
display your kernel version:
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2015-07-27 13:55:26 -04:00
|
|
|
$ uname -r
|
2015-04-29 15:51:57 -04:00
|
|
|
3.11.0-15-generic
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
>**Note**: If you previously installed Docker using `APT`, make sure you update
|
|
|
|
your `APT` sources to the new Docker repository.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
|
|
|
### Update your apt sources
|
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
Docker's `APT` repository contains Docker 1.7.1 and higher. To set `APT` to use
|
2015-09-28 17:01:52 -04:00
|
|
|
packages from the new repository:
|
|
|
|
|
2016-01-27 00:08:15 -05:00
|
|
|
1. Log into your machine as a user with `sudo` or `root` privileges.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
|
|
|
2. Open a terminal window.
|
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
3. Update package information, ensure that APT works with the `https` method, and that CA certificates are installed.
|
|
|
|
|
2016-01-27 00:08:15 -05:00
|
|
|
$ sudo apt-get update
|
|
|
|
$ sudo apt-get install apt-transport-https ca-certificates
|
2016-01-06 07:46:53 -05:00
|
|
|
|
|
|
|
4. Add the new `GPG` key.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
2015-11-06 06:16:57 -05:00
|
|
|
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
2015-09-28 17:01:52 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
5. Open the `/etc/apt/sources.list.d/docker.list` file in your favorite editor.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
|
|
|
If the file doesn't exist, create it.
|
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
6. Remove any existing entries.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
7. Add an entry for your Ubuntu operating system.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
|
|
|
The possible entries are:
|
|
|
|
|
2015-11-10 05:17:53 -05:00
|
|
|
- On Ubuntu Precise 12.04 (LTS)
|
|
|
|
|
|
|
|
deb https://apt.dockerproject.org/repo ubuntu-precise main
|
|
|
|
|
|
|
|
- On Ubuntu Trusty 14.04 (LTS)
|
|
|
|
|
|
|
|
deb https://apt.dockerproject.org/repo ubuntu-trusty main
|
|
|
|
|
|
|
|
- Ubuntu Wily 15.10
|
|
|
|
|
|
|
|
deb https://apt.dockerproject.org/repo ubuntu-wily main
|
2015-09-28 17:01:52 -04:00
|
|
|
|
2016-03-02 10:05:00 -05:00
|
|
|
> **Note**: Docker does not provide packages for all architectures. You can find
|
|
|
|
> nightly built binaries in https://master.dockerproject.org. To install docker on
|
2015-11-24 13:25:57 -05:00
|
|
|
> a multi-architecture system, add an `[arch=...]` clause to the entry. Refer to the
|
|
|
|
> [Debian Multiarch wiki](https://wiki.debian.org/Multiarch/HOWTO#Setting_up_apt_sources)
|
|
|
|
> for details.
|
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
8. Save and close the `/etc/apt/sources.list.d/docker.list` file.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
9. Update the `APT` package index.
|
2014-10-26 15:42:51 -04:00
|
|
|
|
2016-01-27 00:08:15 -05:00
|
|
|
$ sudo apt-get update
|
2015-07-01 21:16:02 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
10. Purge the old repo if it exists.
|
2015-06-26 17:59:34 -04:00
|
|
|
|
2016-01-27 00:08:15 -05:00
|
|
|
$ sudo apt-get purge lxc-docker
|
2015-06-26 17:59:34 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
11. Verify that `APT` is pulling from the right repository.
|
2014-10-26 15:42:51 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ apt-cache policy docker-engine
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
From now on when you run `apt-get upgrade`, `APT` pulls from the new repository.
|
2015-09-28 17:01:52 -04:00
|
|
|
|
|
|
|
### Prerequisites by Ubuntu Version
|
|
|
|
|
|
|
|
- Ubuntu Wily 15.10
|
|
|
|
- Ubuntu Trusty 14.04 (LTS)
|
2014-12-12 11:57:23 -05:00
|
|
|
|
2016-02-26 07:00:27 -05:00
|
|
|
For Ubuntu Trusty and Wily, it's recommended to install the
|
2015-11-04 13:49:47 -05:00
|
|
|
`linux-image-extra` kernel package. The `linux-image-extra` package
|
|
|
|
allows you use the `aufs` storage driver.
|
|
|
|
|
|
|
|
To install the `linux-image-extra` package for your kernel version:
|
|
|
|
|
|
|
|
1. Open a terminal on your Ubuntu host.
|
|
|
|
|
|
|
|
2. Update your package manager.
|
|
|
|
|
|
|
|
$ sudo apt-get update
|
|
|
|
|
|
|
|
3. Install the recommended package.
|
|
|
|
|
|
|
|
$ sudo apt-get install linux-image-extra-$(uname -r)
|
|
|
|
|
|
|
|
4. Go ahead and install Docker.
|
|
|
|
|
2015-11-25 09:51:23 -05:00
|
|
|
If you are installing on Ubuntu 14.04 or 12.04, `apparmor` is required. You can install it using: `apt-get install apparmor`
|
2015-11-04 13:49:47 -05:00
|
|
|
|
|
|
|
#### Ubuntu Precise 12.04 (LTS)
|
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
For Ubuntu Precise, Docker requires the 3.13 kernel version. If your kernel
|
|
|
|
version is older than 3.13, you must upgrade it. Refer to this table to see
|
|
|
|
which packages are required for your environment:
|
2014-12-12 11:57:23 -05:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
<style type="text/css"> .tg {border-collapse:collapse;border-spacing:0;} .tg
|
|
|
|
td{font-size:14px;padding:10px
|
|
|
|
5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
|
|
|
|
.tg-031{width:275px;font-family:monospace} </style> <table class="tg"> <tr> <td
|
|
|
|
class="tg-031">linux-image-generic-lts-trusty</td> <td class="tg-031e">Generic
|
|
|
|
Linux kernel image. This kernel has AUFS built in. This is required to run
|
|
|
|
Docker.</td> </tr> <tr> <td class="tg-031">linux-headers-generic-lts-trusty</td>
|
|
|
|
<td class="tg-031e">Allows packages such as ZFS and VirtualBox guest additions
|
|
|
|
which depend on them. If you didn't install the headers for your existing
|
|
|
|
kernel, then you can skip these headers for the"trusty" kernel. If you're
|
|
|
|
unsure, you should include this package for safety.</td> </tr> <tr> <td
|
|
|
|
class="tg-031">xserver-xorg-lts-trusty</td> <td class="tg-031e"
|
|
|
|
rowspan="2">Optional in non-graphical environments without Unity/Xorg.
|
2015-09-28 17:01:52 -04:00
|
|
|
<b>Required</b> when running Docker on machine with a graphical environment.
|
|
|
|
<br>
|
|
|
|
<br>To learn more about the reasons for these packages, read the installation
|
2015-03-12 18:23:56 -04:00
|
|
|
instructions for backported kernels, specifically the <a
|
|
|
|
href="https://wiki.ubuntu.com/Kernel/LTSEnablementStack" target="_blank">LTS
|
2015-09-28 17:01:52 -04:00
|
|
|
Enablement Stack</a> — refer to note 5 under each version.
|
|
|
|
</td> </tr>
|
2015-03-12 18:23:56 -04:00
|
|
|
<tr> <td class="tg-031">libgl1-mesa-glx-lts-trusty</td> </tr> </table>
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
To upgrade your kernel and install the additional packages, do the following:
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
1. Open a terminal on your Ubuntu host.
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
2. Update your package manager.
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo apt-get update
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
3. Install both the required and optional packages.
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo apt-get install linux-image-generic-lts-trusty
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
Depending on your environment, you may install more as described in the preceding table.
|
2014-06-09 16:33:04 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
4. Reboot your host.
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo reboot
|
2014-04-23 07:03:03 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
5. After your system reboots, go ahead and install Docker.
|
|
|
|
|
|
|
|
## Install
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-10-21 01:24:23 -04:00
|
|
|
Make sure you have installed the prerequisites for your Ubuntu version.
|
|
|
|
|
|
|
|
Then,
|
2015-03-12 18:23:56 -04:00
|
|
|
install Docker using the following:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
1. Log into your Ubuntu installation as a user with `sudo` privileges.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2016-01-06 07:46:53 -05:00
|
|
|
2. Update your `APT` package index.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo apt-get update
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
3. Install Docker.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ sudo apt-get install docker-engine
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-03 16:02:17 -04:00
|
|
|
4. Start the `docker` daemon.
|
2015-08-06 07:41:33 -04:00
|
|
|
|
|
|
|
$ sudo service docker start
|
|
|
|
|
|
|
|
5. Verify `docker` is installed correctly.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo docker run hello-world
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
This command downloads a test image and runs it in a container. When the
|
|
|
|
container runs, it prints an informational message. Then, it exits.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
## Optional configurations
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
This section contains optional procedures for configuring your Ubuntu to work
|
|
|
|
better with Docker.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
* [Create a docker group](#create-a-docker-group)
|
|
|
|
* [Adjust memory and swap accounting](#adjust-memory-and-swap-accounting)
|
|
|
|
* [Enable UFW forwarding](#enable-ufw-forwarding)
|
|
|
|
* [Configure a DNS server for use by Docker](#configure-a-dns-server-for-use-by-docker)
|
2015-06-26 17:59:34 -04:00
|
|
|
* [Configure Docker to start on boot](#configure-docker-to-start-on-boot)
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-21 11:50:09 -04:00
|
|
|
### Create a Docker group
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
The `docker` daemon binds to a Unix socket instead of a TCP port. By default
|
|
|
|
that Unix socket is owned by the user `root` and other users can access it with
|
|
|
|
`sudo`. For this reason, `docker` daemon always runs as the `root` user.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
To avoid having to use `sudo` when you use the `docker` command, create a Unix
|
|
|
|
group called `docker` and add users to it. When the `docker` daemon starts, it
|
|
|
|
makes the ownership of the Unix socket read/writable by the `docker` group.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
>**Warning**: The `docker` group is equivalent to the `root` user; For details
|
|
|
|
>on how this impacts security in your system, see [*Docker Daemon Attack
|
2016-01-23 23:36:40 -05:00
|
|
|
>Surface*](../../security/security.md#docker-daemon-attack-surface) for details.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
To create the `docker` group and add your user:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
1. Log into Ubuntu as a user with `sudo` privileges.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
This procedure assumes you log in as the `ubuntu` user.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2016-03-08 10:33:14 -05:00
|
|
|
2. Create the `docker` group.
|
|
|
|
|
|
|
|
$ sudo groupadd docker
|
|
|
|
|
|
|
|
3. Add your user to `docker` group.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo usermod -aG docker ubuntu
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2016-03-08 10:33:14 -05:00
|
|
|
4. Log out and log back in.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
This ensures your user is running with the correct permissions.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2016-03-08 10:33:14 -05:00
|
|
|
5. Verify your work by running `docker` without `sudo`.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ docker run hello-world
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-22 05:19:18 -04:00
|
|
|
If this fails with a message similar to this:
|
|
|
|
|
2015-07-22 15:37:17 -04:00
|
|
|
Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
|
2015-04-22 05:19:18 -04:00
|
|
|
|
|
|
|
Check that the `DOCKER_HOST` environment variable is not set for your shell.
|
|
|
|
If it is, unset it.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
### Adjust memory and swap accounting
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
When users run Docker, they may see these messages when working with an image:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
WARNING: Your kernel does not support cgroup swap limit. WARNING: Your
|
|
|
|
kernel does not support swap limit capabilities. Limitation discarded.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-08-07 08:31:33 -04:00
|
|
|
To prevent these messages, enable memory and swap accounting on your
|
|
|
|
system. Enabling memory and swap accounting does induce both a memory
|
|
|
|
overhead and a performance degradation even when Docker is not in
|
|
|
|
use. The memory overhead is about 1% of the total available
|
|
|
|
memory. The performance degradation is roughly 10%.
|
|
|
|
|
|
|
|
To enable memory and swap on system using GNU GRUB (GNU GRand Unified
|
|
|
|
Bootloader), do the following:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
1. Log into Ubuntu as a user with `sudo` privileges.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
2. Edit the `/etc/default/grub` file.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
3. Set the `GRUB_CMDLINE_LINUX` value as follows:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
4. Save and close the file.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
5. Update GRUB.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo update-grub
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
6. Reboot your system.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2014-10-26 15:42:51 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
### Enable UFW forwarding
|
2014-10-26 15:42:51 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
If you use [UFW (Uncomplicated Firewall)](https://help.ubuntu.com/community/UFW)
|
|
|
|
on the same host as you run Docker, you'll need to do additional configuration.
|
|
|
|
Docker uses a bridge to manage container networking. By default, UFW drops all
|
|
|
|
forwarding traffic. As a result, for Docker to run when UFW is
|
|
|
|
enabled, you must set UFW's forwarding policy appropriately.
|
2014-10-26 15:42:51 -04:00
|
|
|
|
2015-08-21 09:28:49 -04:00
|
|
|
Also, UFW's default set of rules denies all incoming traffic. If you want to
|
|
|
|
reach your containers from another host allow incoming connections on the Docker
|
|
|
|
port. The Docker port defaults to `2376` if TLS is enabled or `2375` when it is
|
|
|
|
not. If TLS is not enabled, communication is unencrypted. By default, Docker
|
|
|
|
runs without TLS enabled.
|
2014-10-26 15:42:51 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
To configure UFW and allow incoming connections on the Docker port:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
1. Log into Ubuntu as a user with `sudo` privileges.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
2. Verify that UFW is installed and enabled.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo ufw status
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
3. Open the `/etc/default/ufw` file for editing.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo nano /etc/default/ufw
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
4. Set the `DEFAULT_FORWARD_POLICY` policy to:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
DEFAULT_FORWARD_POLICY="ACCEPT"
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
5. Save and close the file.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
6. Reload UFW to use the new setting.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo ufw reload
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
7. Allow incoming connections on the Docker port.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo ufw allow 2375/tcp
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
### Configure a DNS server for use by Docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
Systems that run Ubuntu or an Ubuntu derivative on the desktop typically use
|
|
|
|
`127.0.0.1` as the default `nameserver` in `/etc/resolv.conf` file. The
|
|
|
|
NetworkManager also sets up `dnsmasq` to use the real DNS servers of the
|
|
|
|
connection and sets up `nameserver 127.0.0.1` in /`etc/resolv.conf`.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
When starting containers on desktop machines with these configurations, Docker
|
|
|
|
users see this warning:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers
|
|
|
|
can't use it. Using default external servers : [8.8.8.8 8.8.4.4]
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
The warning occurs because Docker containers can't use the local DNS nameserver.
|
|
|
|
Instead, Docker defaults to using an external nameserver.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
To avoid this warning, you can specify a DNS server for use by Docker
|
2015-04-10 20:58:23 -04:00
|
|
|
containers. Or, you can disable `dnsmasq` in NetworkManager. Though, disabling
|
2015-03-12 18:23:56 -04:00
|
|
|
`dnsmasq` might make DNS resolution slower on some networks.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-12-02 11:08:54 -05:00
|
|
|
The instructions below describe how to configure the Docker daemon
|
|
|
|
running on Ubuntu 14.10 or below. Ubuntu 15.04 and above use `systemd`
|
|
|
|
as the boot and service manager. Refer to [control and configure Docker
|
2016-01-23 23:36:40 -05:00
|
|
|
with systemd](../../admin/systemd.md#custom-docker-daemon-options) to
|
2015-12-02 11:08:54 -05:00
|
|
|
configure a daemon controlled by `systemd`.
|
2015-11-18 23:35:34 -05:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
To specify a DNS server for use by Docker:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
1. Log into Ubuntu as a user with `sudo` privileges.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
2. Open the `/etc/default/docker` file for editing.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo nano /etc/default/docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
3. Add a setting for Docker.
|
2014-05-01 10:13:34 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
DOCKER_OPTS="--dns 8.8.8.8"
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
Replace `8.8.8.8` with a local DNS server such as `192.168.1.1`. You can also
|
|
|
|
specify multiple DNS servers. Separated them with spaces, for example:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
--dns 8.8.8.8 --dns 192.168.1.1
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
>**Warning**: If you're doing this on a laptop which connects to various
|
|
|
|
>networks, make sure to choose a public DNS server.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
4. Save and close the file.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
5. Restart the Docker daemon.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo restart docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
|
|
|
|
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
**Or, as an alternative to the previous procedure,** disable `dnsmasq` in
|
|
|
|
NetworkManager (this might slow your network).
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-01 15:45:37 -04:00
|
|
|
1. Open the `/etc/NetworkManager/NetworkManager.conf` file for editing.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
$ sudo nano /etc/NetworkManager/NetworkManager.conf
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2016-01-20 01:12:22 -05:00
|
|
|
2. Comment out the `dns=dnsmasq` line:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
dns=dnsmasq
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
3. Save and close the file.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
4. Restart both the NetworkManager and Docker.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ sudo restart network-manager
|
2015-09-13 16:29:50 -04:00
|
|
|
$ sudo restart docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-06-26 17:59:34 -04:00
|
|
|
### Configure Docker to start on boot
|
|
|
|
|
|
|
|
Ubuntu uses `systemd` as its boot and service manager `15.04` onwards and `upstart`
|
|
|
|
for versions `14.10` and below.
|
|
|
|
|
|
|
|
For `15.04` and up, to configure the `docker` daemon to start on boot, run
|
|
|
|
|
|
|
|
$ sudo systemctl enable docker
|
|
|
|
|
|
|
|
For `14.10` and below the above installation method automatically configures `upstart`
|
|
|
|
to start the docker daemon on boot
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-03-12 18:23:56 -04:00
|
|
|
## Upgrade Docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
To install the latest version of Docker with `apt-get`:
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2016-01-31 23:59:21 -05:00
|
|
|
$ sudo apt-get upgrade docker-engine
|
2014-04-15 20:53:12 -04:00
|
|
|
|
2015-04-29 15:51:57 -04:00
|
|
|
## Uninstallation
|
|
|
|
|
|
|
|
To uninstall the Docker package:
|
|
|
|
|
2015-07-15 17:01:04 -04:00
|
|
|
$ sudo apt-get purge docker-engine
|
2015-04-29 15:51:57 -04:00
|
|
|
|
|
|
|
To uninstall the Docker package and dependencies that are no longer needed:
|
|
|
|
|
2015-07-15 17:01:04 -04:00
|
|
|
$ sudo apt-get autoremove --purge docker-engine
|
2015-04-29 15:51:57 -04:00
|
|
|
|
|
|
|
The above commands will not remove images, containers, volumes, or user created
|
|
|
|
configuration files on your host. If you wish to delete all images, containers,
|
|
|
|
and volumes run the following command:
|
|
|
|
|
|
|
|
$ rm -rf /var/lib/docker
|
|
|
|
|
|
|
|
You must delete the user created configuration files manually.
|