github.com/eikeon/docker@v1.5.0-rc4/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 the following versions of Ubuntu: 8 9 - [*Ubuntu Trusty 14.04 (LTS) (64-bit)*](#ubuntu-trusty-1404-lts-64-bit) 10 - [*Ubuntu Precise 12.04 (LTS) (64-bit)*](#ubuntu-precise-1204-lts-64-bit) 11 - [*Ubuntu Raring 13.04 and Saucy 13.10 (64 12 bit)*](#ubuntu-raring-1304-and-saucy-1310-64-bit) 13 14 Please read [*Docker and UFW*](#docker-and-ufw), if you plan to use [UFW 15 (Uncomplicated Firewall)](https://help.ubuntu.com/community/UFW) 16 17 ## Ubuntu Trusty 14.04 (LTS) (64-bit) 18 19 Ubuntu Trusty comes with a 3.13.0 Linux kernel, and a `docker.io` package which 20 installs Docker 1.0.1 and all its prerequisites from Ubuntu's repository. 21 22 > **Note**: 23 > Ubuntu (and Debian) contain a much older KDE3/GNOME2 package called ``docker``, so the 24 > Ubuntu-maintained package and executable are named ``docker.io``. 25 26 ### Ubuntu-maintained Package Installation 27 28 To install the latest Ubuntu package (this is **not** the most recent Docker release): 29 30 $ sudo apt-get update 31 $ sudo apt-get install docker.io 32 33 Then, to enable tab-completion of Docker commands in BASH, either restart BASH or: 34 35 $ source /etc/bash_completion.d/docker.io 36 37 > **Note**: 38 > Since the Ubuntu package is quite dated at this point, you may want to use 39 > the following section to install the most recent release of Docker. 40 > If you install the Docker version, you do not need to install ``docker.io`` from Ubuntu. 41 42 ### Docker-maintained Package Installation 43 44 If you'd like to try the latest version of Docker: 45 46 First, check that your APT system can deal with `https` 47 URLs: the file `/usr/lib/apt/methods/https` 48 should exist. If it doesn't, you need to install the package 49 `apt-transport-https`. 50 51 [ -e /usr/lib/apt/methods/https ] || { 52 apt-get update 53 apt-get install apt-transport-https 54 } 55 56 Then, add the Docker repository key to your local keychain. 57 58 $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 59 60 Add the Docker repository to your apt sources list, update and install 61 the `lxc-docker` package. 62 63 *You may receive a warning that the package isn't trusted. Answer yes to 64 continue installation.* 65 66 $ sudo sh -c "echo deb https://get.docker.com/ubuntu docker main\ 67 > /etc/apt/sources.list.d/docker.list" 68 $ sudo apt-get update 69 $ sudo apt-get install lxc-docker 70 71 > **Note**: 72 > 73 > There is also a simple `curl` script available to help with this process. 74 > 75 > $ curl -sSL https://get.docker.com/ubuntu/ | sudo sh 76 77 To verify that everything has worked as expected: 78 79 $ sudo docker run -i -t ubuntu /bin/bash 80 81 Which should download the `ubuntu` image, and then start `bash` in a container. 82 83 ## Ubuntu Precise 12.04 (LTS) (64-bit) 84 85 This installation path should work at all times. 86 87 ### Dependencies 88 89 **Linux kernel 3.8** 90 91 Due to a bug in LXC, Docker works best on the 3.8 kernel. Precise comes 92 with a 3.2 kernel, so we need to upgrade it. The kernel you'll install 93 when following these steps comes with AUFS built in. We also include the 94 generic headers to enable packages that depend on them, like ZFS and the 95 VirtualBox guest additions. If you didn't install the headers for your 96 "precise" kernel, then you can skip these headers for the "raring" 97 kernel. But it is safer to include them if you're not sure. 98 99 Please read the installation instructions for backported kernels at 100 Ubuntu.org to understand why you also need to install the Xorg packages 101 when running Docker on a machine with a graphical environment like Unity. 102 [LTS Enablement Stack](https://wiki.ubuntu.com/Kernel/LTSEnablementStack) refer to note 5 under 103 each version. 104 105 # install the backported kernel 106 $ sudo apt-get update 107 $ sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring 108 109 # install the backported kernel and xorg if using Unity/Xorg 110 $ sudo apt-get install --install-recommends linux-generic-lts-raring xserver-xorg-lts-raring libgl1-mesa-glx-lts-raring 111 112 # reboot 113 $ sudo reboot 114 115 ### Installation 116 117 > **Warning**: 118 > These instructions have changed for 0.6. If you are upgrading from an 119 > earlier version, you will need to follow them again. 120 121 Docker is available as a Debian package, which makes installation easy. 122 **See the** [*Mirrors*](#mirrors) **section below if you are not 123 in the United States.** Other sources of the Debian packages may be 124 faster for you to install. 125 126 First, check that your APT system can deal with `https` 127 URLs: the file `/usr/lib/apt/methods/https` 128 should exist. If it doesn't, you need to install the package 129 `apt-transport-https`. 130 131 [ -e /usr/lib/apt/methods/https ] || { 132 apt-get update 133 apt-get install apt-transport-https 134 } 135 136 Then, add the Docker repository key to your local keychain. 137 138 $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 139 140 Add the Docker repository to your apt sources list, update and install 141 the `lxc-docker` package. 142 143 *You may receive a warning that the package isn't trusted. Answer yes to 144 continue installation.* 145 146 $ sudo sh -c "echo deb https://get.docker.com/ubuntu docker main\ 147 > /etc/apt/sources.list.d/docker.list" 148 $ sudo apt-get update 149 $ sudo apt-get install lxc-docker 150 151 > **Note**: 152 > 153 > There is also a simple `curl` script available to help with this process. 154 > 155 > $ curl -sSL https://get.docker.com/ubuntu/ | sudo sh 156 157 Now verify that the installation has worked by downloading the 158 `ubuntu` image and launching a container. 159 160 $ sudo docker run -i -t ubuntu /bin/bash 161 162 Type `exit` to exit 163 164 **Done!**, continue with the [User Guide](/userguide/). 165 166 ## Ubuntu Raring 13.04 and Saucy 13.10 (64 bit) 167 168 These instructions cover both Ubuntu Raring 13.04 and Saucy 13.10. 169 170 ### Dependencies 171 172 **Optional AUFS filesystem support** 173 174 Ubuntu Raring already comes with the 3.8 kernel, so we don't need to 175 install it. However, not all systems have AUFS filesystem support 176 enabled. AUFS support is optional as of version 0.7, but it's still 177 available as a driver and we recommend using it if you can. 178 179 To make sure AUFS is installed, run the following commands: 180 181 $ sudo apt-get update 182 $ sudo apt-get install linux-image-extra-`uname -r` 183 184 ### Installation 185 186 Docker is available as a Debian package, which makes installation easy. 187 188 > **Warning**: 189 > Please note that these instructions have changed for 0.6. If you are 190 > upgrading from an earlier version, you will need to follow them again. 191 192 First add the Docker repository key to your local keychain. 193 194 $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 195 196 Add the Docker repository to your apt sources list, update and install 197 the `lxc-docker` package. 198 199 $ sudo sh -c "echo deb http://get.docker.com/ubuntu docker main\ 200 > /etc/apt/sources.list.d/docker.list" 201 $ sudo apt-get update 202 $ sudo apt-get install lxc-docker 203 204 Now verify that the installation has worked by downloading the 205 `ubuntu` image and launching a container. 206 207 $ sudo docker run -i -t ubuntu /bin/bash 208 209 Type `exit` to exit 210 211 **Done!**, now continue with the [User Guide](/userguide/). 212 213 ### Upgrade 214 215 To install the latest version of Docker, use the standard 216 `apt-get` method: 217 218 # update your sources list 219 $ sudo apt-get update 220 221 # install the latest 222 $ sudo apt-get install lxc-docker 223 224 ## Giving non-root access 225 226 The `docker` daemon always runs as the `root` user, and since Docker 227 version 0.5.2, the `docker` daemon binds to a Unix socket instead of a 228 TCP port. By default that Unix socket is owned by the user `root`, and 229 so, by default, you can access it with `sudo`. 230 231 Starting in version 0.5.3, if you (or your Docker installer) create a 232 Unix group called `docker` and add users to it, then the `docker` daemon 233 will make the ownership of the Unix socket read/writable by the `docker` 234 group when the daemon starts. The `docker` daemon must always run as the 235 `root` user, but if you run the `docker` client as a user in the 236 `docker` group then you don't need to add `sudo` to all the client 237 commands. From Docker 0.9.0 you can use the `-G` flag to specify an 238 alternative group. 239 240 > **Warning**: 241 > The `docker` group (or the group specified with the `-G` flag) is 242 > `root`-equivalent; see [*Docker Daemon Attack Surface*]( 243 > /articles/security/#docker-daemon-attack-surface) for details. 244 245 **Example:** 246 247 # Add the docker group if it doesn't already exist. 248 $ sudo groupadd docker 249 250 # Add the connected user "${USER}" to the docker group. 251 # Change the user name to match your preferred user. 252 # You may have to logout and log back in again for 253 # this to take effect. 254 $ sudo gpasswd -a ${USER} docker 255 256 # Restart the Docker daemon. 257 # If you are in Ubuntu 14.04, use docker.io instead of docker 258 $ sudo service docker restart 259 260 ## Memory and Swap Accounting 261 262 If you want to enable memory and swap accounting, you must add the 263 following command-line parameters to your kernel: 264 265 cgroup_enable=memory swapaccount=1 266 267 On systems using GRUB (which is the default for Ubuntu), you can add 268 those parameters by editing `/etc/default/grub` and 269 extending `GRUB_CMDLINE_LINUX`. Look for the 270 following line: 271 272 GRUB_CMDLINE_LINUX="" 273 274 And replace it by the following one: 275 276 GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" 277 278 Then run `sudo update-grub`, and reboot. 279 280 These parameters will help you get rid of the following warnings: 281 282 WARNING: Your kernel does not support cgroup swap limit. 283 WARNING: Your kernel does not support swap limit capabilities. Limitation discarded. 284 285 ## Troubleshooting 286 287 On Linux Mint, the `cgroup-lite` and `apparmor` packages are not 288 installed by default. Before Docker will work correctly, you will need 289 to install this via: 290 291 $ sudo apt-get update && sudo apt-get install cgroup-lite apparmor 292 293 ## Docker and UFW 294 295 Docker uses a bridge to manage container networking. By default, UFW 296 drops all forwarding traffic. As a result you will need to enable UFW 297 forwarding: 298 299 $ sudo nano /etc/default/ufw 300 301 # Change: 302 # DEFAULT_FORWARD_POLICY="DROP" 303 # to 304 DEFAULT_FORWARD_POLICY="ACCEPT" 305 306 Then reload UFW: 307 308 $ sudo ufw reload 309 310 UFW's default set of rules denies all incoming traffic. If you want to 311 be able to reach your containers from another host then you should allow 312 incoming connections on the Docker port (default 2375): 313 314 $ sudo ufw allow 2375/tcp 315 316 ## Docker and local DNS server warnings 317 318 Systems which are running Ubuntu or an Ubuntu derivative on the desktop 319 will use 127.0.0.1 as the default nameserver in /etc/resolv.conf. 320 NetworkManager sets up dnsmasq to use the real DNS servers of the 321 connection and sets up nameserver 127.0.0.1 in /etc/resolv.conf. 322 323 When starting containers on these desktop machines, users will see a 324 warning: 325 326 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] 327 328 This warning is shown because the containers can't use the local DNS 329 nameserver and Docker will default to using an external nameserver. 330 331 This can be worked around by specifying a DNS server to be used by the 332 Docker daemon for the containers: 333 334 $ sudo nano /etc/default/docker 335 --- 336 # Add: 337 DOCKER_OPTS="--dns 8.8.8.8" 338 # 8.8.8.8 could be replaced with a local DNS server, such as 192.168.1.1 339 # multiple DNS servers can be specified: --dns 8.8.8.8 --dns 192.168.1.1 340 341 The Docker daemon has to be restarted: 342 343 $ sudo restart docker 344 345 > **Warning**: 346 > If you're doing this on a laptop which connects to various networks, 347 > make sure to choose a public DNS server. 348 349 An alternative solution involves disabling dnsmasq in NetworkManager by 350 following these steps: 351 352 $ sudo nano /etc/NetworkManager/NetworkManager.conf 353 ---- 354 # Change: 355 dns=dnsmasq 356 # to 357 #dns=dnsmasq 358 359 NetworkManager and Docker need to be restarted afterwards: 360 361 $ sudo restart network-manager 362 $ sudo restart docker 363 364 > **Warning**: This might make DNS resolution slower on some networks. 365 366 ## Mirrors 367 368 You should `ping get.docker.com` and compare the 369 latency to the following mirrors, and pick whichever one is best for 370 you. 371 372 ### Yandex 373 374 [Yandex](http://yandex.ru/) in Russia is mirroring the Docker Debian 375 packages, updating every 6 hours. 376 Substitute `http://mirror.yandex.ru/mirrors/docker/` for 377 `http://get.docker.com/ubuntu` in the instructions above. 378 For example: 379 380 $ sudo sh -c "echo deb http://mirror.yandex.ru/mirrors/docker/ docker main\ 381 > /etc/apt/sources.list.d/docker.list" 382 $ sudo apt-get update 383 $ sudo apt-get install lxc-docker