2015-06-07 23:07:20 -04:00
|
|
|
<!--[metadata]>
|
|
|
|
+++
|
|
|
|
title = "Installation on Debian"
|
|
|
|
description = "Instructions for installing Docker on Debian."
|
|
|
|
keywords = ["Docker, Docker documentation, installation, debian"]
|
|
|
|
[menu.main]
|
|
|
|
parent = "smn_linux"
|
2015-09-28 17:01:52 -04:00
|
|
|
weight=-2
|
2015-06-07 23:07:20 -04:00
|
|
|
+++
|
|
|
|
<![end-metadata]-->
|
2014-05-17 16:28:39 -04:00
|
|
|
|
|
|
|
# Debian
|
|
|
|
|
|
|
|
Docker is supported on the following versions of Debian:
|
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
- [*Debian testing stretch (64-bit)*](#debian-wheezy-stable-7-x-64-bit)
|
2014-12-12 19:45:22 -05:00
|
|
|
- [*Debian 8.0 Jessie (64-bit)*](#debian-jessie-80-64-bit)
|
2015-07-01 00:01:00 -04:00
|
|
|
- [*Debian 7.7 Wheezy (64-bit)*](#debian-wheezy-stable-7-x-64-bit)
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
>**Note**: If you previously installed Docker using `apt`, make sure you update
|
|
|
|
your `apt` sources to the new `apt` repository.
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
## Prerequisites
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
Docker requires a 64-bit installation regardless of your Debian 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-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -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-05-17 16:28:39 -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:
|
2015-04-17 08:54:40 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ uname -r
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
### Update your apt repository
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
Docker's `apt` repository contains Docker 1.7.1 and higher. To set `apt` to use
|
|
|
|
from the new repository:
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
1. If you haven't already done so, log into your machine as a user with `sudo` or `root` privileges.
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
2. Open a terminal window.
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
3. Purge any older repositories.
|
2015-07-28 16:19:34 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ apt-get purge lxc-docker*
|
|
|
|
$ apt-get purge docker.io*
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
4. Add the new `gpg` key.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-11-06 06:16:57 -05:00
|
|
|
$ apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
5. Open the `/etc/apt/sources.list.d/docker.list` file in your favorite editor.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
If the file doesn't exist, create it.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
6. Remove any existing entries.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
7. Add an entry for your Debian operating system.
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
The possible entries are:
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-11-24 10:32:43 -05:00
|
|
|
- On Debian Wheezy
|
2015-11-10 05:17:53 -05:00
|
|
|
|
|
|
|
deb https://apt.dockerproject.org/repo debian-wheezy main
|
|
|
|
|
|
|
|
- On Debian Jessie
|
|
|
|
|
|
|
|
deb https://apt.dockerproject.org/repo debian-jessie main
|
|
|
|
|
|
|
|
- On Debian Stretch/Sid
|
|
|
|
|
|
|
|
deb https://apt.dockerproject.org/repo debian-stretch main
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
8. Save and close the file.
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
9. Update the `apt` package index.
|
2015-03-11 12:56:04 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ apt-get update
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
10. Verify that `apt` is pulling from the right repository.
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ apt-cache policy docker-engine
|
2015-03-11 12:56:04 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
From now on when you run `apt-get upgrade`, `apt` pulls from the new apt repository.
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
## Install Docker
|
2015-03-11 12:56:04 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
Before installing Docker, make sure you have set your `apt` repository correctly as described in the prerequisites.
|
2015-04-07 01:01:34 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
1. Update the `apt` package index.
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ sudo apt-get update
|
2015-04-07 01:01:34 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
2. Install Docker.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ sudo apt-get install docker-engine
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
5. Start the `docker` daemon.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ sudo service docker start
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
6. Verify `docker` is installed correctly.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
$ sudo docker run hello-world
|
2015-04-29 15:51:57 -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.
|
2015-04-29 15:51:57 -04:00
|
|
|
|
|
|
|
|
2014-08-24 06:18:56 -04:00
|
|
|
## Giving non-root access
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2014-05-21 17:05:19 -04:00
|
|
|
The `docker` daemon always runs as the `root` user and 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`.
|
|
|
|
|
|
|
|
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 client commands. From Docker 0.9.0 you can
|
|
|
|
use the `-G` flag to specify an alternative group.
|
2014-05-17 16:28:39 -04:00
|
|
|
|
2015-03-11 12:56:04 -04:00
|
|
|
> **Warning**:
|
2014-05-17 16:28:39 -04:00
|
|
|
> The `docker` group (or the group specified with the `-G` flag) is
|
2015-10-09 19:50:41 -04:00
|
|
|
> `root`-equivalent; see [*Docker Daemon Attack Surface*](../articles/security.md#docker-daemon-attack-surface) details.
|
2014-05-17 16:28:39 -04:00
|
|
|
|
|
|
|
**Example:**
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# Restart the Docker daemon.
|
|
|
|
$ sudo service docker restart
|
|
|
|
|
2015-09-28 17:01:52 -04:00
|
|
|
## Upgrade Docker
|
|
|
|
|
|
|
|
To install the latest version of Docker with `apt-get`:
|
|
|
|
|
|
|
|
$ apt-get upgrade docker-engine
|
|
|
|
|
|
|
|
## Uninstall
|
|
|
|
|
|
|
|
To uninstall the Docker package:
|
|
|
|
|
|
|
|
$ sudo apt-get purge docker-engine
|
|
|
|
|
|
|
|
To uninstall the Docker package and dependencies that are no longer needed:
|
|
|
|
|
|
|
|
$ sudo apt-get autoremove --purge docker-engine
|
|
|
|
|
|
|
|
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.
|
2014-08-24 06:18:56 -04:00
|
|
|
|
2014-05-21 17:05:19 -04:00
|
|
|
## What next?
|
|
|
|
|
2015-11-22 20:15:39 -05:00
|
|
|
Continue with the [User Guide](../userguide/index.md).
|