Docker

 
 
Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux. Docker uses resource isolation features of the Linux kernel such as cgroups and kernel namespaces to allow independent "containers" to run within a single Linux instance, avoiding the overhead of starting virtual machines.

The latest Docker version can be downloaded from: http://www.docker.com







Installing Docker on Windows



Information
none

Operating system used
Windows Vista Home Premium SP 2

Software prerequisites
Oracle VM VirtualBox on Windows.

Procedure
  1. Download Ubuntu 14.04.2 Server install image for 64-bit PC (AMD64) computers
    For example: D:\docker\ubuntu-14.04.2-server-amd64.iso

    Note:
    You need to install the 64-bit Ubuntu version because Docker version 1.5.0 only support 64-bit.
    There is no server install image for 64-bit PC (Intel x86) computers.
    I have installed the ubuntu-14.04.2-server-amd64.iso on a 32-bit PC (Intel x86) and it works.
    Intended for lab exercises and not for production.

  2. Follow procedure Install Ubuntu inside Windows using VirtualBox, but use the 64-bit server install image (AMD64) instead of the 32-bit server install image (Intel x86)

    Note:
    After installation the Ubuntu 14.04.2.vdi size is: 1,69 GB (1.824.522.240 bytes)

  3. Start the Oracle VM VirtualBox Manager, select the installed Ubuntu VM and start it.

  4. The Ubuntu VM is running and a terminal opens. Please login.

    Ubuntu VM login

  5. To avoid typing sudo command constantly, switch to root, type: sudo su

  6. Check if Docker is installed/running, type: service docker.io status
    You should see:
    docker.io: unrecognized service

  7. Docker will run on any modern Linux distro with a 64-bit architecture and a Linux kernel version of minimal 3.8. To check this, type: uname -a
    You should see:
    Linux ubuntu14 3.16.0-30-generic ...

  8. Sync up our package index from source, type: apt-get update

    Note:
    The apt-get utility is a powerful and free package management command line program, that is used to work with Ubuntu's APT (Advanced Packaging Tool) library to perform installation of new software packages, removing existing software packages, upgrading of existing software packages and even used to upgrading the entire operating system.

    The update command is used to resynchronize the package index files from their sources specified in /etc/apt/sources.list file.
    The update command fetched the packages from their locations and update the packages to newer version.

  9. Install Docker, type: apt-get install -y docker.io

    Note:
    The Docker package installs the Docker client and Docker deamon.

  10. Again, check if Docker is installed/running, type: service docker.io status
    You should see:
    docker.io start/running, process nnnn

    Note:
    Docker will automatically start if we start the Ubuntu machine.

  11. Now that the Docker deamon is running, we can execute Docker commands.
    Show Docker version, type: docker -v
    You should see:
    Docker version 1.0.1, build 990021a

  12. Show Docker version (more information), type: docker version

  13. Show Docker information, type: docker info

  14. To install a newer version of Docker on the Ubuntu server, do the following:

    • Add the Docker repo key to your local apt key chain, type:
      wget -qO- https://get.docker.com/gpg | apt-key add -
      You should see:
      OK

    • Add the Docker repo to our app sources, type:
      echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list

    • Sync up with the new repo, type: apt-get update

    • Check/install the latest Docker version, type: apt-get install lxc-docker
      Install the latest Docker version, type: Y

    • Check your current Docker version, type: docker -v
      You should see:
      Docker version 1.5.0, build a8a31ef

  15. Do some Docker configuration to make Docker CLI (Command Line Interface) easier:
    • Docker needs root to work.
      Docker deamon listens on a local Unix socket: /var/run/docker.sock
      Note: /var/run is a symbolic link to /run

      Docker socket

      docker.sock has user root and group docker.
      If you add users to the group docker, the sudo prefix command is not needed anymore.

      WARNING:
      FOR SECURITY REASONS ONLY USERS WHO NEED ROOT ACCESS SHOULD BE ADDED TO THIS GROUP!


    • Exit the root account, back to your own account, type: exit

    • Open a new docker container, type: docker run -it ubuntu /bin/bash
      This will be denied because your are not root.

    • Add a user to the Docker group, but first check if the Docker group exists, type: cat /etc/group

    • Add your account (eg: robert) to the group docker, type: sudo gpasswd -a robert docker

    • When you make changes to the group file, you need to logout Ubuntu and login again:
      • Type:logout

      • Login again:
        Username: robert
        Password: mysecret

    • Open a new Docker container, type: docker run -it ubuntu /bin/bash
      A new Docker container opens without the need to use the sudo prefix command.

    • To exit the container, type: exit