Monday, March 2, 2015

Installing Docker on Ubuntu

What is Docker?


Docker is a container-based software framework for automating deployment of applications. “Containers” are encapsulated, lightweight, and portable application modules.

Environment

  1. Ubuntu 14.10
  2. Docker 1.2.0 or 1.4.0


Ubuntu Package Installation


Ubuntu-maintained package installation is simple, but does not contain the most recent Docker release. At the time of this article, Docker 1.4.0 is available, but the instructions below will install 1.2.0. Check with your cloud provider for container compatbility.

Prior to using any Ubuntu-maintained package installation, ensure existing packages are up to date:
$ sudo apt-get update

Install Docker:
$ sudo apt-get -y install docker.io
Note: Ubuntu (and Debian) contain a much older KDE3/GNOME2 package called docker, so the Ubuntu-maintained package and executable are named docker.io.

Link and Fix Paths:
$ ln -sf /usr/bin/docker.io /usr/local/bin/docker
$ sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker

Configure Docker to start when the server boots:
$ update-rc.d docker defaults



Docker-maintained Package Installation


Use this approach to install the latest version of Docker.

Add the Docker repository key to your local keychain:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.TI1OtMmq4G --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
gpg: requesting key A88D21E9 from hkp server keyserver.ubuntu.com
gpg: key A88D21E9: public key "Docker Release Tool (releasedocker) <docker@dotcloud.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Add the Docker repository to your apt sources list:
$ sudo sh -c "echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

Prior to using any Ubuntu-maintained package installation, ensure existing packages are up to date:
$ sudo apt-get update

Install the Docker-LXC package:
$ sudo apt-get install lxc-docker

To verify that everything has worked as expected, download the ubuntu image, and then start bash in a container:
$ sudo docker run -i -t ubuntu /bin/bash
root@6932168c97d3:/# exit
exit
$ 



Script


The complete script for this article:
# add the Docker repository key to your local keychain: 
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

# add the Docker repository to your apt sources list: 
sudo sh -c "echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

# prior to using any Ubuntu-maintained package installation, ensure existing packages are up to date: 
sudo apt-get update

# install the Docker-LXC package: 
sudo apt-get install lxc-docker -y

# install docker compose
wget https://github.com/docker/compose/releases/download/1.1.0/docker-compose-$(uname -s)-$(uname -m)
mv docker-compose-$(uname -s)-$(uname -m) docker-compose
sudo chmod 777 docker-compose
sudo mv docker-compose /usr/local/bin/
docker-compose --version



References

  1. Resources:
    1. [GitHub] Docker Installation Script (Debian/Ubuntu)
    2. [GitHub] Dockerfiles (that I've extended or created)
  2. [Docker] Installation on Ubuntu
  3. [LiquidWeb] Installing Docker on 14.04

No comments:

Post a Comment