2014-02-09 14:40:31 +02:00
|
|
|
:title: Installation on Ubuntu
|
2013-05-21 11:47:16 -06:00
|
|
|
:description: Please note this project is currently under heavy development. It should not be used in production.
|
|
|
|
:keywords: Docker, Docker documentation, requirements, virtualbox, vagrant, git, ssh, putty, cygwin, linux
|
|
|
|
|
2013-08-27 14:29:49 -07:00
|
|
|
.. _ubuntu_linux:
|
|
|
|
|
2013-11-26 00:16:30 -05:00
|
|
|
Ubuntu
|
|
|
|
======
|
2013-04-22 18:38:42 -07:00
|
|
|
|
2013-10-16 14:38:24 -07:00
|
|
|
.. warning::
|
|
|
|
|
|
|
|
These instructions have changed for 0.6. If you are upgrading from
|
|
|
|
an earlier version, you will need to follow them again.
|
|
|
|
|
2013-08-28 17:26:10 -07:00
|
|
|
.. include:: install_header.inc
|
2013-04-22 18:38:42 -07:00
|
|
|
|
2013-11-26 02:45:32 +00:00
|
|
|
Docker is supported on the following versions of Ubuntu:
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-05-15 16:11:59 -07:00
|
|
|
- :ref:`ubuntu_precise`
|
2014-01-07 11:46:07 -08:00
|
|
|
- :ref:`ubuntu_raring_saucy`
|
2013-05-15 16:11:59 -07:00
|
|
|
|
2013-08-28 17:26:10 -07:00
|
|
|
Please read :ref:`ufw`, if you plan to use `UFW (Uncomplicated
|
|
|
|
Firewall) <https://help.ubuntu.com/community/UFW>`_
|
2013-07-30 13:47:29 +02:00
|
|
|
|
2013-05-15 16:11:59 -07:00
|
|
|
.. _ubuntu_precise:
|
|
|
|
|
|
|
|
Ubuntu Precise 12.04 (LTS) (64-bit)
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
This installation path should work at all times.
|
2013-03-26 08:50:34 -07:00
|
|
|
|
2013-04-23 12:04:53 -07:00
|
|
|
|
|
|
|
Dependencies
|
|
|
|
------------
|
|
|
|
|
2013-05-15 16:11:59 -07:00
|
|
|
**Linux kernel 3.8**
|
|
|
|
|
2014-01-21 07:26:45 +00:00
|
|
|
Due to a bug in LXC, Docker works best on the 3.8 kernel. Precise
|
2013-08-28 17:26:10 -07:00
|
|
|
comes with a 3.2 kernel, so we need to upgrade it. The kernel you'll
|
2013-10-16 14:38:24 -07:00
|
|
|
install when following these steps comes with AUFS built in. We also
|
|
|
|
include the generic headers to enable packages that depend on them,
|
|
|
|
like ZFS and the VirtualBox guest additions. If you didn't install the
|
|
|
|
headers for your "precise" kernel, then you can skip these headers for
|
|
|
|
the "raring" kernel. But it is safer to include them if you're not
|
|
|
|
sure.
|
2013-05-15 16:11:59 -07:00
|
|
|
|
2013-04-23 12:04:53 -07:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2013-05-15 16:11:59 -07:00
|
|
|
# install the backported kernel
|
2013-08-06 13:56:29 -07:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
|
2013-05-15 16:11:59 -07:00
|
|
|
|
|
|
|
# reboot
|
|
|
|
sudo reboot
|
2013-04-23 12:04:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
2013-10-16 14:38:24 -07:00
|
|
|
.. warning::
|
|
|
|
|
2013-08-28 17:26:10 -07:00
|
|
|
These instructions have changed for 0.6. If you are upgrading from
|
|
|
|
an earlier version, you will need to follow them again.
|
|
|
|
|
2013-12-05 18:08:56 -08:00
|
|
|
Docker is available as a Debian package, which makes installation
|
2014-03-06 23:33:08 +02:00
|
|
|
easy. **See the** :ref:`installmirrors` **section below if you are not in
|
2013-12-05 18:08:56 -08:00
|
|
|
the United States.** Other sources of the Debian packages may be
|
|
|
|
faster for you to install.
|
2013-08-23 10:41:53 -07:00
|
|
|
|
2014-04-03 13:50:19 -07:00
|
|
|
First, check that your APT system can deal with ``https`` URLs:
|
|
|
|
the file ``/usr/lib/apt/methods/https`` should exist. If it doesn't,
|
|
|
|
you need to install the package ``apt-transport-https``.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
[ -e /usr/lib/apt/methods/https ] || {
|
|
|
|
apt-get update
|
|
|
|
apt-get install apt-transport-https
|
|
|
|
}
|
|
|
|
|
|
|
|
Then, add the Docker repository key to your local keychain.
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-05-15 16:11:59 -07:00
|
|
|
.. code-block:: bash
|
2013-03-26 08:50:34 -07:00
|
|
|
|
2014-03-18 17:10:22 +01:00
|
|
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
|
2013-08-23 12:56:03 -07:00
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
Add the Docker repository to your apt sources list, update and install the
|
2013-12-11 11:27:36 -08:00
|
|
|
``lxc-docker`` package.
|
2013-11-26 00:58:17 -05:00
|
|
|
|
|
|
|
*You may receive a warning that the package isn't trusted. Answer yes to
|
|
|
|
continue installation.*
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2014-04-03 13:50:19 -07:00
|
|
|
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main\
|
2013-10-17 09:31:35 +02:00
|
|
|
> /etc/apt/sources.list.d/docker.list"
|
2013-05-15 16:11:59 -07:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install lxc-docker
|
|
|
|
|
2013-12-03 14:17:59 -05:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
There is also a simple ``curl`` script available to help with this process.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2013-12-11 11:27:36 -08:00
|
|
|
curl -s https://get.docker.io/ubuntu/ | sudo sh
|
2013-12-03 14:17:59 -05:00
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
Now verify that the installation has worked by downloading the ``ubuntu`` image
|
|
|
|
and launching a container.
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-04-19 20:59:43 -07:00
|
|
|
.. code-block:: bash
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-08-13 18:05:35 -07:00
|
|
|
sudo docker run -i -t ubuntu /bin/bash
|
2013-05-15 16:11:59 -07:00
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
Type ``exit`` to exit
|
2013-05-15 16:11:59 -07:00
|
|
|
|
|
|
|
**Done!**, now continue with the :ref:`hello_world` example.
|
|
|
|
|
2014-01-07 11:46:07 -08:00
|
|
|
.. _ubuntu_raring_saucy:
|
2013-05-15 16:11:59 -07:00
|
|
|
|
2014-01-07 11:46:07 -08:00
|
|
|
Ubuntu Raring 13.04 and Saucy 13.10 (64 bit)
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
These instructions cover both Ubuntu Raring 13.04 and Saucy 13.10.
|
2013-05-15 16:11:59 -07:00
|
|
|
|
|
|
|
Dependencies
|
|
|
|
------------
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-11-26 02:45:32 +00:00
|
|
|
**Optional AUFS filesystem support**
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-10-16 14:38:24 -07:00
|
|
|
Ubuntu Raring already comes with the 3.8 kernel, so we don't need to install it. However, not all systems
|
2013-11-26 02:45:32 +00:00
|
|
|
have AUFS filesystem support enabled. AUFS support is optional as of version 0.7, but it's still available as
|
|
|
|
a driver and we recommend using it if you can.
|
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
To make sure AUFS is installed, run the following commands:
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-04-19 20:59:43 -07:00
|
|
|
.. code-block:: bash
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-04-19 20:59:43 -07:00
|
|
|
sudo apt-get update
|
2013-05-15 16:11:59 -07:00
|
|
|
sudo apt-get install linux-image-extra-`uname -r`
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-06-03 17:29:41 -04:00
|
|
|
|
2013-05-15 16:11:59 -07:00
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
2013-08-23 10:41:53 -07:00
|
|
|
Docker is available as a Debian package, which makes installation easy.
|
2013-05-15 16:11:59 -07:00
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
.. warning::
|
|
|
|
|
|
|
|
Please note that these instructions have changed for 0.6. If you are upgrading from an earlier version, you will need
|
|
|
|
to follow them again.
|
|
|
|
|
2013-12-27 15:18:40 +00:00
|
|
|
First add the Docker repository key to your local keychain.
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-04-19 20:59:43 -07:00
|
|
|
.. code-block:: bash
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2014-03-19 00:00:48 +01:00
|
|
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
|
2013-08-23 12:56:03 -07:00
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
Add the Docker repository to your apt sources list, update and install the
|
|
|
|
``lxc-docker`` package.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2013-10-17 10:07:12 +02:00
|
|
|
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\
|
|
|
|
> /etc/apt/sources.list.d/docker.list"
|
2013-05-15 16:11:59 -07:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install lxc-docker
|
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
Now verify that the installation has worked by downloading the ``ubuntu`` image
|
|
|
|
and launching a container.
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-04-19 20:59:43 -07:00
|
|
|
.. code-block:: bash
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-08-13 18:05:35 -07:00
|
|
|
sudo docker run -i -t ubuntu /bin/bash
|
2013-05-15 16:11:59 -07:00
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
Type ``exit`` to exit
|
2013-03-25 19:52:52 -07:00
|
|
|
|
2013-04-22 18:38:42 -07:00
|
|
|
**Done!**, now continue with the :ref:`hello_world` example.
|
2013-07-30 13:47:29 +02:00
|
|
|
|
2014-01-21 02:10:32 +00:00
|
|
|
|
|
|
|
Giving non-root access
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
The ``docker`` daemon always runs as the root user, and since Docker version
|
|
|
|
0.5.2, 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 so, by default, you
|
|
|
|
can access it with ``sudo``.
|
|
|
|
|
|
|
|
Starting in version 0.5.3, if you (or your Docker installer) create a
|
|
|
|
Unix group called *docker* and add users to it, then the ``docker``
|
|
|
|
daemon will make the ownership of the Unix socket read/writable by the
|
|
|
|
*docker* group when the daemon starts. The ``docker`` daemon must
|
|
|
|
always run as the root user, but if you run the ``docker`` client as a user in
|
|
|
|
the *docker* group then you don't need to add ``sudo`` to all the
|
2014-01-24 16:18:02 -08:00
|
|
|
client commands. As of 0.9.0, you can specify that a group other than ``docker``
|
|
|
|
should own the Unix socket with the ``-G`` option.
|
|
|
|
|
|
|
|
.. warning:: The *docker* group (or the group specified with ``-G``) is
|
2014-03-20 09:08:52 +10:00
|
|
|
root-equivalent; see :ref:`dockersecurity_daemon` details.
|
2014-01-21 02:10:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
**Example:**
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
# Add the docker group if it doesn't already exist.
|
|
|
|
sudo groupadd docker
|
|
|
|
|
|
|
|
# Add the connected user "${USER}" to the docker group.
|
|
|
|
# Change the user name to match your preferred user.
|
|
|
|
# You may have to logout and log back in again for
|
|
|
|
# this to take effect.
|
|
|
|
sudo gpasswd -a ${USER} docker
|
|
|
|
|
2014-01-21 07:26:45 +00:00
|
|
|
# Restart the Docker daemon.
|
2014-01-21 02:10:32 +00:00
|
|
|
sudo service docker restart
|
|
|
|
|
|
|
|
|
|
|
|
Upgrade
|
2014-01-16 00:17:23 +00:00
|
|
|
--------
|
|
|
|
|
|
|
|
To install the latest version of docker, use the standard ``apt-get`` method:
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
# update your sources list
|
|
|
|
sudo apt-get update
|
|
|
|
|
|
|
|
# install the latest
|
|
|
|
sudo apt-get install lxc-docker
|
|
|
|
|
2014-02-19 16:53:15 -07:00
|
|
|
Memory and Swap Accounting
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2014-04-12 10:57:19 +00:00
|
|
|
If you want to enable memory and swap accounting, you must add the following
|
2014-02-19 16:53:15 -07:00
|
|
|
command-line parameters to your kernel::
|
|
|
|
|
|
|
|
cgroup_enable=memory swapaccount=1
|
|
|
|
|
|
|
|
On systems using GRUB (which is the default for Ubuntu), you can add those
|
|
|
|
parameters by editing ``/etc/default/grub`` and extending
|
|
|
|
``GRUB_CMDLINE_LINUX``. Look for the following line::
|
|
|
|
|
|
|
|
GRUB_CMDLINE_LINUX=""
|
|
|
|
|
|
|
|
And replace it by the following one::
|
|
|
|
|
|
|
|
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
|
|
|
|
|
2014-04-12 10:57:19 +00:00
|
|
|
Then run ``sudo update-grub``, and reboot.
|
|
|
|
|
|
|
|
These parameters will help you get rid of the following warnings::
|
|
|
|
|
|
|
|
WARNING: Your kernel does not support cgroup swap limit.
|
|
|
|
WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.
|
2014-02-19 16:53:15 -07:00
|
|
|
|
2014-01-30 20:53:27 +10:00
|
|
|
Troubleshooting
|
|
|
|
^^^^^^^^^^^^^^^
|
|
|
|
|
2014-02-19 08:53:31 -05:00
|
|
|
On Linux Mint, the ``cgroup-lite`` package is not installed by default.
|
2014-01-30 20:53:27 +10:00
|
|
|
Before Docker will work correctly, you will need to install this via:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2014-02-19 08:53:31 -05:00
|
|
|
sudo apt-get update && sudo apt-get install cgroup-lite
|
2014-01-16 00:17:23 +00:00
|
|
|
|
2013-07-30 13:47:29 +02:00
|
|
|
.. _ufw:
|
|
|
|
|
|
|
|
Docker and UFW
|
|
|
|
^^^^^^^^^^^^^^
|
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
Docker uses a bridge to manage container networking. By default, UFW drops all
|
2014-01-29 23:07:23 -05:00
|
|
|
`forwarding` traffic. As a result you will need to enable UFW forwarding:
|
2013-07-30 13:47:29 +02:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo nano /etc/default/ufw
|
|
|
|
----
|
|
|
|
# Change:
|
|
|
|
# DEFAULT_FORWARD_POLICY="DROP"
|
|
|
|
# to
|
|
|
|
DEFAULT_FORWARD_POLICY="ACCEPT"
|
|
|
|
|
|
|
|
Then reload UFW:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo ufw reload
|
|
|
|
|
|
|
|
|
2013-11-26 00:58:17 -05:00
|
|
|
UFW's default set of rules denies all `incoming` traffic. If you want to be
|
|
|
|
able to reach your containers from another host then you should allow
|
|
|
|
incoming connections on the Docker port (default 4243):
|
2013-10-16 14:38:24 -07:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo ufw allow 4243/tcp
|
|
|
|
|
2014-02-20 19:43:00 +02:00
|
|
|
Docker and local DNS server warnings
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Systems which are running Ubuntu or an Ubuntu derivative on the desktop will
|
|
|
|
use `127.0.0.1` as the default nameserver in `/etc/resolv.conf`. NetworkManager
|
|
|
|
sets up dnsmasq to use the real DNS servers of the connection and sets up
|
|
|
|
`nameserver 127.0.0.1` in `/etc/resolv.conf`.
|
|
|
|
|
|
|
|
When starting containers on these desktop machines, users will see a warning:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
This warning is shown because the containers can't use the local DNS nameserver
|
|
|
|
and Docker will default to using an external nameserver.
|
|
|
|
|
|
|
|
This can be worked around by specifying a DNS server to be used by the Docker
|
|
|
|
daemon for the containers:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo nano /etc/default/docker
|
|
|
|
---
|
|
|
|
# Add:
|
2014-03-13 11:46:02 -06:00
|
|
|
DOCKER_OPTS="--dns 8.8.8.8"
|
2014-02-20 19:43:00 +02:00
|
|
|
# 8.8.8.8 could be replaced with a local DNS server, such as 192.168.1.1
|
2014-03-13 11:46:02 -06:00
|
|
|
# multiple DNS servers can be specified: --dns 8.8.8.8 --dns 192.168.1.1
|
2014-02-20 19:43:00 +02:00
|
|
|
|
|
|
|
The Docker daemon has to be restarted:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo restart docker
|
|
|
|
|
|
|
|
.. warning:: If you're doing this on a laptop which connects to various networks, make sure to choose a public DNS server.
|
|
|
|
|
|
|
|
An alternative solution involves disabling dnsmasq in NetworkManager by
|
|
|
|
following these steps:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo nano /etc/NetworkManager/NetworkManager.conf
|
|
|
|
----
|
|
|
|
# Change:
|
|
|
|
dns=dnsmasq
|
|
|
|
# to
|
|
|
|
#dns=dnsmasq
|
|
|
|
|
|
|
|
NetworkManager and Docker need to be restarted afterwards:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo restart network-manager
|
|
|
|
sudo restart docker
|
|
|
|
|
|
|
|
.. warning:: This might make DNS resolution slower on some networks.
|
|
|
|
|
2014-03-31 10:39:02 -07:00
|
|
|
.. _installmirrors:
|
|
|
|
|
2013-12-05 18:08:56 -08:00
|
|
|
Mirrors
|
|
|
|
^^^^^^^
|
|
|
|
|
|
|
|
You should ``ping get.docker.io`` and compare the latency to the
|
|
|
|
following mirrors, and pick whichever one is best for you.
|
|
|
|
|
|
|
|
Yandex
|
|
|
|
------
|
|
|
|
|
|
|
|
`Yandex <http://yandex.ru/>`_ in Russia is mirroring the Docker Debian
|
|
|
|
packages, updating every 6 hours. Substitute
|
|
|
|
``http://mirror.yandex.ru/mirrors/docker/`` for
|
|
|
|
``http://get.docker.io/ubuntu`` in the instructions above. For example:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
sudo sh -c "echo deb http://mirror.yandex.ru/mirrors/docker/ docker main\
|
|
|
|
> /etc/apt/sources.list.d/docker.list"
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install lxc-docker
|