github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/docs/sources/installation/ubuntulinux.md (about) 1 page_title: Installation on Ubuntu 2 page_description: Instructions for installing Docker on Ubuntu. 3 page_keywords: Docker, Docker documentation, requirements, virtualbox, installation, ubuntu 4 5 #Ubuntu 6 7 Docker is supported on these Ubuntu operating systems: 8 9 - Ubuntu Trusty 14.04 (LTS) 10 - Ubuntu Precise 12.04 (LTS) 11 - Ubuntu Saucy 13.10 12 13 This page instructs you to install using Docker-managed release packages and 14 installation mechanisms. Using these packages ensures you get the latest release 15 of Docker. If you wish to install using Ubuntu-managed packages, consult your 16 Ubuntu documentation. 17 18 ##Prerequisites 19 20 Docker requires a 64-bit installation regardless of your Ubuntu version. 21 Additionally, your kernel must be 3.10 at minimum. The latest 3.10 minor version 22 or a newer maintained version are also acceptable. 23 24 Kernels older than 3.10 lack some of the features required to run Docker 25 containers. These older versions are known to have bugs which cause data loss 26 and frequently panic under certain conditions. 27 28 To check your current kernel version, open a terminal and use `uname -r` to display 29 your kernel version: 30 31 $ uname -r 32 3.11.0-15-generic 33 34 >**Caution** Some Ubuntu OS versions **require a version higher than 3.10** to 35 >run Docker, see the prerequisites on this page that apply to your Ubuntu 36 >version. 37 38 ###For Trusty 14.04 39 40 There are no prerequisites for this version. 41 42 ###For Precise 12.04 (LTS) 43 44 For Ubuntu Precise, Docker requires the 3.13 kernel version. If your kernel 45 version is older than 3.13, you must upgrade it. Refer to this table to see 46 which packages are required for your environment: 47 48 <style type="text/css"> .tg {border-collapse:collapse;border-spacing:0;} .tg 49 td{font-size:14px;padding:10px 50 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;} 51 .tg-031{width:275px;font-family:monospace} </style> <table class="tg"> <tr> <td 52 class="tg-031">linux-image-generic-lts-trusty</td> <td class="tg-031e">Generic 53 Linux kernel image. This kernel has AUFS built in. This is required to run 54 Docker.</td> </tr> <tr> <td class="tg-031">linux-headers-generic-lts-trusty</td> 55 <td class="tg-031e">Allows packages such as ZFS and VirtualBox guest additions 56 which depend on them. If you didn't install the headers for your existing 57 kernel, then you can skip these headers for the"trusty" kernel. If you're 58 unsure, you should include this package for safety.</td> </tr> <tr> <td 59 class="tg-031">xserver-xorg-lts-trusty</td> <td class="tg-031e" 60 rowspan="2">Optional in non-graphical environments without Unity/Xorg. 61 <i>Required</i> when running Docker on machine with a graphical environment. 62 63 <p>To learn more about the reasons for these packages, read the installation 64 instructions for backported kernels, specifically the <a 65 href="https://wiki.ubuntu.com/Kernel/LTSEnablementStack" target="_blank">LTS 66 Enablement Stack</a> — refer to note 5 under each version.</p></td> </tr> 67 <tr> <td class="tg-031">libgl1-mesa-glx-lts-trusty</td> </tr> </table> 68 69 To upgrade your kernel and install the additional packages, do the following: 70 71 1. Open a terminal on your Ubuntu host. 72 73 2. Update your package manager. 74 75 $ sudo apt-get update 76 77 3. Install both the required and optional packages. 78 79 $ sudo apt-get install linux-image-generic-lts-trusty 80 81 Depending on your environment, you may install more as described in the preceding table. 82 83 4. Reboot your host. 84 85 $ sudo reboot 86 87 5. After your system reboots, go ahead and [install Docker](#installing-docker-on-ubuntu). 88 89 90 ###For Saucy 13.10 (64 bit) 91 92 Docker uses AUFS as the default storage backend. If you don't have this 93 prerequisite installed, Docker's installation process adds it. 94 95 ##Installing Docker on Ubuntu 96 97 Make sure you have installed the prerequisites for your Ubuntu version. Then, 98 install Docker using the following: 99 100 1. Log into your Ubuntu installation as a user with `sudo` privileges. 101 102 2. Verify that you have `wget` installed. 103 104 $ which wget 105 106 If `wget` isn't installed, install it after updating your manager: 107 108 $ sudo apt-get update 109 $ sudo apt-get install wget 110 111 3. Get the latest Docker package. 112 113 $ wget -qO- https://get.docker.com/ | sh 114 115 The system prompts you for your `sudo` password. Then, it downloads and 116 installs Docker and its dependencies. 117 >**Note**: If your company is behind a filtering proxy, you may find that the 118 >`apt-key` 119 >command fails for the Docker repo during installation. To work around this, 120 >add the key directly using the following: 121 > 122 > $ wget -qO- https://get.docker.com/gpg | sudo apt-key add - 123 124 4. Verify `docker` is installed correctly. 125 126 $ sudo docker run hello-world 127 128 This command downloads a test image and runs it in a container. 129 130 ## Optional configurations for Docker on Ubuntu 131 132 This section contains optional procedures for configuring your Ubuntu to work 133 better with Docker. 134 135 * [Create a docker group](#create-a-docker-group) 136 * [Adjust memory and swap accounting](#adjust-memory-and-swap-accounting) 137 * [Enable UFW forwarding](#enable-ufw-forwarding) 138 * [Configure a DNS server for use by Docker](#configure-a-dns-server-for-docker) 139 140 ### Create a Docker group 141 142 The `docker` daemon binds to a Unix socket instead of a TCP port. By default 143 that Unix socket is owned by the user `root` and other users can access it with 144 `sudo`. For this reason, `docker` daemon always runs as the `root` user. 145 146 To avoid having to use `sudo` when you use the `docker` command, create a Unix 147 group called `docker` and add users to it. When the `docker` daemon starts, it 148 makes the ownership of the Unix socket read/writable by the `docker` group. 149 150 >**Warning**: The `docker` group is equivalent to the `root` user; For details 151 >on how this impacts security in your system, see [*Docker Daemon Attack 152 >Surface*](/articles/security/#docker-daemon-attack-surface) for details. 153 154 To create the `docker` group and add your user: 155 156 1. Log into Ubuntu as a user with `sudo` privileges. 157 158 This procedure assumes you log in as the `ubuntu` user. 159 160 3. Create the `docker` group and add your user. 161 162 $ sudo usermod -aG docker ubuntu 163 164 3. Log out and log back in. 165 166 This ensures your user is running with the correct permissions. 167 168 4. Verify your work by running `docker` without `sudo`. 169 170 $ docker run hello-world 171 172 173 ### Adjust memory and swap accounting 174 175 When users run Docker, they may see these messages when working with an image: 176 177 WARNING: Your kernel does not support cgroup swap limit. WARNING: Your 178 kernel does not support swap limit capabilities. Limitation discarded. 179 180 To prevent these messages, enable memory and swap accounting on your system. To 181 enable these on system using GNU GRUB (GNU GRand Unified Bootloader), do the 182 following. 183 184 1. Log into Ubuntu as a user with `sudo` privileges. 185 186 2. Edit the `/etc/default/grub` file. 187 188 3. Set the `GRUB_CMDLINE_LINUX` value as follows: 189 190 GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" 191 192 4. Save and close the file. 193 194 5. Update GRUB. 195 196 $ sudo update-grub 197 198 6. Reboot your system. 199 200 201 ### Enable UFW forwarding 202 203 If you use [UFW (Uncomplicated Firewall)](https://help.ubuntu.com/community/UFW) 204 on the same host as you run Docker, you'll need to do additional configuration. 205 Docker uses a bridge to manage container networking. By default, UFW drops all 206 forwarding traffic. As a result, for Docker to run when UFW is 207 enabled, you must set UFW's forwarding policy appropriately. 208 209 Also, UFW's default set of rules denies all incoming traffic. If you want to be able 210 to reach your containers from another host then you should also allow incoming 211 connections on the Docker port (default `2375`). 212 213 To configure UFW and allow incoming connections on the Docker port: 214 215 1. Log into Ubuntu as a user with `sudo` privileges. 216 217 2. Verify that UFW is installed and enabled. 218 219 $ sudo ufw status 220 221 3. Open the `/etc/default/ufw` file for editing. 222 223 $ sudo nano /etc/default/ufw 224 225 4. Set the `DEFAULT_FORWARD_POLICY` policy to: 226 227 DEFAULT_FORWARD_POLICY="ACCEPT" 228 229 5. Save and close the file. 230 231 6. Reload UFW to use the new setting. 232 233 $ sudo ufw reload 234 235 7. Allow incoming connections on the Docker port. 236 237 $ sudo ufw allow 2375/tcp 238 239 ### Configure a DNS server for use by Docker 240 241 Systems that run Ubuntu or an Ubuntu derivative on the desktop typically use 242 `127.0.0.1` as the default `nameserver` in `/etc/resolv.conf` file. The 243 NetworkManager also sets up `dnsmasq` to use the real DNS servers of the 244 connection and sets up `nameserver 127.0.0.1` in /`etc/resolv.conf`. 245 246 When starting containers on desktop machines with these configurations, Docker 247 users see this warning: 248 249 WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers 250 can't use it. Using default external servers : [8.8.8.8 8.8.4.4] 251 252 The warning occurs because Docker containers can't use the local DNS nameserver. 253 Instead, Docker defaults to using an external nameserver. 254 255 To avoid this warning, you can specify a DNS server for use by Docker 256 containers. Or, you can disable `dnsmasq` in NetworkManager. Though, disabling 257 `dnsmasq` might make DNS resolution slower on some networks. 258 259 To specify a DNS server for use by Docker: 260 261 1. Log into Ubuntu as a user with `sudo` privileges. 262 263 2. Open the `/etc/default/docker` file for editing. 264 265 $ sudo nano /etc/default/docker 266 267 3. Add a setting for Docker. 268 269 DOCKER_OPTS="--dns 8.8.8.8" 270 271 Replace `8.8.8.8` with a local DNS server such as `192.168.1.1`. You can also 272 specify multiple DNS servers. Separated them with spaces, for example: 273 274 --dns 8.8.8.8 --dns 192.168.1.1 275 276 >**Warning**: If you're doing this on a laptop which connects to various 277 >networks, make sure to choose a public DNS server. 278 279 4. Save and close the file. 280 281 5. Restart the Docker daemon. 282 283 $ sudo restart docker 284 285 286 287 288 289 **Or, as an alternative to the previous procedure,** disable `dnsmasq` in 290 NetworkManager (this might slow your network). 291 292 1. Open the `/etc/NetworkManager/NetworkManager.conf` file for editing. 293 294 $ sudo nano /etc/NetworkManager/NetworkManager.conf 295 296 2. Comment out the `dns=dsnmasq` line: 297 298 dns=dnsmasq 299 300 3. Save and close the file. 301 302 4. Restart both the NetworkManager and Docker. 303 304 $ sudo restart network-manager $ sudo restart docker 305 306 307 ## Upgrade Docker 308 309 To install the latest version of Docker, use the standard `-N` flag with `wget`: 310 311 $ wget -N -qO- https://get.docker.com/ | sh 312