Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Docker

You're reading from   Learning Docker Build, ship, and scale faster

Arrow left icon
Product type Paperback
Published in May 2017
Publisher
ISBN-13 9781786462923
Length 300 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (3):
Arrow left icon
Jeeva S. Chelladhurai Jeeva S. Chelladhurai
Author Profile Icon Jeeva S. Chelladhurai
Jeeva S. Chelladhurai
Pethuru Raj Pethuru Raj
Author Profile Icon Pethuru Raj
Pethuru Raj
Vinod Singh Vinod Singh
Author Profile Icon Vinod Singh
Vinod Singh
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Docker FREE CHAPTER 2. Handling Docker Containers 3. Building Images 4. Publishing Images 5. Running Your Private Docker Infrastructure 6. Running Services in a Container 7. Sharing Data with Containers 8. Orchestrating Containers 9. Testing with Docker 10. Debugging Containers 11. Securing Docker Containers 12. The Docker Platform – Distinct Capabilities and Use Cases

Installing the Docker Engine

The Docker Engine is built on top of the Linux kernel and it extensively leverages Linux kernel features such as namespaces and cgroups. Due to the burgeoning popularity of Docker, it is now being packaged by all the major Linux distributions so that they can retain their loyal users as well as attract new users. You can install the Docker Engine using the corresponding packaging tool of the Linux distribution, for example, using the apt-get command for Debian and Ubuntu, and the yum command for Red Hat, Fedora, and CentOS. Alternatively, you can use the fully automated install script, which will do all the hard work for you behind the scenes.

If you are a Mac or Microsoft Windows user, you can run Docker on Linux emulations (VMs). There are multiple solutions available to run Docker using Linux VM, which is explained in a later subsection. Docker and Microsoft are working towards supporting native Windows containers to run a native Windows application, which is outside the scope of this book.

For all practical purposes, we have chosen the Ubuntu 16.04 LTS (Xenial Xerus) (64-bit) Linux distribution.

Installing Docker on Ubuntu

Docker is currently supported only on 64-bit architecture Linux and the Linux kernel must be 3.10 or later. At the time of writing this book, the latest version of the Docker was
17.03.0-ce. The following steps prescribe the installation procedure of the Docker Engine on Ubuntu Linux 16.04 in detail:

  1. First, the best practice for installing any software in Ubuntu begins with the resynchronization of the package repository. This step will essentially update the package repository in line with the latest published packages, thus we will ensure that we always get the latest published version using the command shown here:
      $ sudo apt-get update
Downloading the example code
You can download the example code files from your account at
http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit
http://www.packtpub.com/support and register to have the files e-mailed directly to you.
  1. Add the Docker package repository path for Ubuntu 16.04 to your APT sources, as shown here:
      $ sudo sh -c "echo deb https://apt.dockerproject.org/repo \
ubuntu-xenial main > /etc/apt/sources.list.d/docker.list"
  1. Add the GNU Privacy Guard (GPG) key by running the following command:
      $ sudo apt-key adv --keyserver \
hkp://p80.pool.sks-keyservers.net:80 --recv-keys \
58118E89F3A912897C070ADBF76221572C52609D
  1. Resynchronize with the package repository using the following command:
      $ sudo apt-get update
  1. Install Docker and start the Docker service:
      $ sudo apt-get install -y docker-engine
  1. Having installed the Docker Engine, let's verify our installation by running docker --version as shown here:
      $ docker --version
Docker version 17.03.0-ce, build 60ccb22

Hurrah!! We have successfully installed Docker version 17.03.0 community edition.

Installing Docker using an automated script

In the previous section, we installed the Docker Engine by manually configuring the GPG key, APT repository, and so on. However, the Docker community has taken a step forward by hiding all these details in an automated install script. This script enables the installation of Docker on most popular Linux distributions, either through the curl command or through the wget command, as shown here:

  • For the curl command:
      $ sudo curl -sSL https://get.docker.io/ | sh
  • For the wget command:
      $ sudo wget -qO- https://get.docker.io/ | sh
The preceding automated script approach enforces AUFS as the underlying Docker filesystem because AUFS is preferred over devicemapper. This script probes the AUFS driver, and then installs it automatically if it is not found in the system. In addition, it also conducts some basic tests upon installation for verifying the sanity.

Installing Docker on the Mac

On a Mac system, you can run Docker on Linux VM. Tools such as Vagrant and Docker Toolbox are quite handy to emulate Linux on Mac and in turn run Docker on it. Docker recently released Docker on Mac as a Beta, using the xhyve hypervisor to provide the Linux emulation. The xhyve hypervisor virtualizes the Docker Engine environment and Linux kernel-specific features for the Docker daemon.

It is always recommended that you use Docker for Mac for supported OS X versions 10.10.3, Yosemite or newer.

The following steps describe the installation of Docker for Mac:

  1. Download Docker for Mac from the link https://download.docker.com/mac/beta/Docker.dmg.
  2. Double-click to download Docker.dmg and move it, as shown here:
  1. Now, double-click on Docker.app in Applications and it will install all Docker components. During installation, it will ask for the machine's administrative password to install the software.
  2. Upon successful installation, the whale icon will appear in the top status bar:
  1. Finally, verify the Docker versions:
      $ docker --version
Docker version 17.03.0-ce, build 60ccb22
$ docker-compose --version
docker-compose version 1.11.2, build dfed245
$ docker-machine --version
docker-machine version 0.10.0, build 76ed2a6

Installing Docker on Windows

As with the Mac, on Windows, you can also run Docker on Linux VMs using tools such as Vagrant and Docker Toolbox. Recently, Docker released a Beta version of Docker for Windows, which uses Hyper-V to virtualize the Docker Engine and Linux kernel-specific features that are essential to run the Docker Engine.

At the time of writing this book, Docker on Windows is supported only on 64-bit Windows 10 Enterprise and Education (1511 November update, Build 10586 or later). In the future, Docker will support more versions of Windows 10. Be aware that the Hyper-V package must be enabled.

It is always recommended that you use Docker native if you have a supported Windows 10 operating system. The following steps are required to install Docker on Windows:

  1. Download the Docker for Windows installer from https://download.docker.com/win/beta/InstallDocker.msi.
  2. Double-click on InstallDocker.msi; the installation wizard will start. It will ask for the Windows administrative password to complete the installation:
  1. Docker starts automatically and the whale will appear in the status bar:
  1. Finally, verify the Docker versions:
      $ docker --version
Docker version 17.03.0-ce, build 60ccb22
$ docker-compose --version
docker-compose version 1.11.2, build dfed245
$ docker-machine --version
docker-machine version 0.10.0, build 76ed2a6

For other versions of Windows, you can install Docker Toolbox from https://docs.docker.com/toolbox/overview/. The Docker Toolbox runs Boot2Docker, a lightweight Linux VM on the Oracle VirtualBox hypervisor and installs the Docker Engine on top of it.

You have been reading a chapter from
Learning Docker - Second Edition
Published in: May 2017
Publisher:
ISBN-13: 9781786462923
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image