Book Image

Native Docker Clustering with Swarm

By : Fabrizio Soppelsa, Chanwit Kaewkasi
Book Image

Native Docker Clustering with Swarm

By: Fabrizio Soppelsa, Chanwit Kaewkasi

Overview of this book

Docker Swarm serves as one of the crucial components of the Docker ecosystem and offers a native solution for you to orchestrate containers. It’s turning out to be one of the preferred choices for Docker clustering thanks to its recent improvements. This book covers Swarm, Swarm Mode, and SwarmKit. It gives you a guided tour on how Swarm works and how to work with Swarm. It describes how to set up local test installations and then moves to huge distributed infrastructures. You will be shown how Swarm works internally, what’s new in Swarmkit, how to automate big Swarm deployments, and how to configure and operate a Swarm cluster on the public and private cloud. This book will teach you how to meet the challenge of deploying massive production-ready applications and a huge number of containers on Swarm. You'll also cover advanced topics that include volumes, scheduling, a Libnetwork deep dive, security, and platform scalability.
Table of Contents (18 chapters)
Native Docker Clustering with Swarm
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Dedication
Preface

Getting started with Swarm


We'll now proceed with the installation of two small Swarm v1 and v2 proof of concept clusters, the first on local and the second on Digital Ocean. In order to execute the recipes, check the list of ingredients, ensure that you have everything, and then begin.

To follow the example, you'll need:

  • Either a Windows, Mac OS X, or Linux desktop

  • A Bash or Bash-compatible shell. On Windows you can either useCygwin or Git Bash.

  • The latest version of VirtualBox, installed for the local example

  • At least 4GB of memory for 4 VirtualBox instances of 1G of memory each for the local example

  • A Docker client, at least version 1.6.0 for Swarm v1 and 1.12 for Swarm v2

  • The latest version of Docker Machine, which is currently 0.8.1

Docker for Mac

Docker announced the desktop version of Docker for Mac and Docker for Windows early in 2016. It's better than the Docker Toolbox, since it includes the Docker CLI tools you expect but doesn't use boot2docker and VirtualBox anymore (it uses unikernels instead, which we'll introduce in Chapter 11, What is Next?) and it's fully integrated into the operating system (Mac OS X Sierra or Windows 10 with Hyper-V enabled).

You can download the Docker desktop from https://www.docker.com/products/overview#/install_the_platform and install it easily.

Just drag and drop the Docker beta icon to your applications folder if you're using Mac OS X. Input your beta registration code, if any, and it's done.

On OS X, you will have the Docker whale in the system tray, which you can open and also configure your settings. A Docker host will be running natively on your desktop.

Docker for Windows

In the case of Docker for Windows, it requires Windows 10 with Hyper-V enabled. Basically, Hyper-V comes with Windows 10 Professional or higher versions. After double-clicking on the setup program, you'll see that the first screen, showing the License Agreement, looks similar to the following screenshot. The setup program will request you for a key similar to that of Docker for Mac.

If the installation process goes smoothly, you will see that the finish screen is ready for you to launch Docker for Windows, as shown:

At the time of launch, Docker will initialize itself to the Hyper-V. Once the process is done, you can just open PowerShell and start using Docker.

If something goes wrong you can open the logging Windows from the tray icon's menu, as well as check with Hyper-V Manager.

Getting ready with Linux

We'll extensively use Machine in this book, so ensure that you have it installed through Docker for Mac or Windows or Docker Toolbox. If you use Linux on your desktop, install the Docker client with your package system (apt or rpm). You will also have to download the bare machine binary, just curl it and assign it the execution permissions; follow the instructions at https://docs.docker.com/machine/install-machine/. The current stable version is 0.8.1.

$ curl -L 
https://github.com/docker/machine/releases/download/v0.8.1/docker-
machine-uname -s-uname -m > /usr/local/bin/docker-machine
$ chmod +x /usr/local/bin/docker-machine`

Check that Docker Machine is available - all systems

You can check that the machine is ready to be used with the following command from the command line:

$ docker-machine --version
docker-machine version 0.8.1, build 41b3b25

If you have problems, please control the system paths or download the correct binary for your architecture.