Howto use Docker Swarm Mode on OpenPower Servers

Docker Engine 1.12 and later versions include the swarm mode for natively managing a cluster of Docker Engine hosts (called swarm). You can use the Docker command-line interface (CLI) to create a swarm and deploy services to a swarm.
In this article, we’ll see how to use the Docker Swarm mode on OpenPOWER servers.
You can find more details about the Docker Swarm mode at:

Here is a quick recap of some of the key terms used in the context of Docker Swarm.

SwarmKit is a toolkit for orchestrating distributed systems. It includes primitives for node discovery, raft-based consensus, task scheduling, and so on. You can find more details about SwarmKit at:

A swarm is a cluster of Docker Engines. The Docker Engine CLI includes the commands for swarm management (such as adding and removing nodes) and commands for deploying services onto the swarm.

A node is where the Docker Engine is running and it is part of the swarm. Nodes can either be worker nodes or manager nodes.
Manager nodes perform the orchestration and cluster management functions required to maintain the required state of the swarm. Manager nodes elect a single leader to conduct orchestration tasks.
Worker nodes receive and run tasks dispatched from manager nodes.

Service and task
A service is the definition of the task that is run on the worker node. The service definition includes a specific Docker image to be used.

Steps to Setup Swarm

The following steps guide you through the process of setting up a swarm cluster.

Step 1. Getting Docker Engine for Power platforms

For Power® platforms, Docker is already part of Ubuntu from Vivid version 15.04 and later, SUSE Linux Enterprise Server (SLES) 12 and later, and Fedora version 23 and later. You can download the relevant packages from distribution repositories. Additionally,  you can download the binaries from the Docker Master Binaries website . The binaries are prefixed with the linux/ppc64le/ tag. Binary packages for RHEL 7 LE is available at Unicamp repository or IBM yum repository.

Step 2. Set up swarm

On a node designated as the manager node, run the following command:

# docker swarm init --advertise-addr
Swarm initialized: current node (0gqevumsltdkz8bo8a4ybprii) is now a manager.

To add a worker to this swarm, run the following command:
    docker swarm join \
    --token SWMTKN-1-14dpd920dwirq5k6bqm3h4x1lwy4m1fiopdiw3ykorlxkio9aq-do6misrpzzx77r4jwd4qfvu02 \

To add a manager to this swarm, run the following command:
    docker swarm join \
    --token SWMTKN-1-14dpd920dwirq5k6bqm3h4x1lwy4m1fiopdiw3ykorlxkio9aq-11mlah1d25fsxihj8sj4bmryo \

The output specifies the command to be used to add worker nodes to the swarm. Run the specified command on all the nodes that you want to be added as a worker node.

Run the docker node ls command on the manager node to view the nodes in a swarm.

# docker node ls
0gqevumsltdkz8bo8a4ybprii    *pkb-rhel71-1  Ready   Active        Leader
0snc3k2kuwdgx2obijvvf3zvq     pkb-rhel71-2  Ready   Active
9bck58xolilxic1b188ae1kac     pkb-rhel71-3  Ready   Active

Step 3: Create a service for deploying to swarm

Run the docker service create command on the manager node to create a service.

# docker service create ppc64le/mysql

# docker service ls
ID            NAME          REPLICAS  IMAGE            COMMAND
794lmhdqvj0d  dreamy_euler  1/1       ppc64le/mysql

Run the docker service inspect command to view details about the service.

# docker service inspect 794lmhdqvj0d
        "ID": "794lmhdqvj0dt17oj1sywgw7o",
        "Version": {
            "Index": 158
        "CreatedAt": "2016-12-06T08:55:18.622742Z",
        "UpdatedAt": "2016-12-06T08:55:18.622742Z",
        "Spec": {
            "Name": "dreamy_euler",
            "TaskTemplate": {
                "ContainerSpec": {
                    "Image": "ppc64le/mysql"
                "Resources": {
                    "Limits": {},
                    "Reservations": {}
                "RestartPolicy": {
                    "Condition": "any",
                    "MaxAttempts": 0
                "Placement": {}
            "Mode": {
                "Replicated": {
                    "Replicas": 1
            "UpdateConfig": {
                "Parallelism": 1,
                "FailureAction": "pause"
            "EndpointSpec": {
                "Mode": "vip"
        "Endpoint": {
            "Spec": {}
        "UpdateStatus": {
            "StartedAt": "0001-01-01T00:00:00Z",
            "CompletedAt": "0001-01-01T00:00:00Z"

Step 4: Swarm constraints

It is possible to limit the nodes on which the tasks get scheduled by using constraints. For example, if you want to run a task on a specific node, you can run the following command:

# docker service create --constraint 'node.hostname == pkb-rhel71-2'  ppc64le/mysql

# docker service ls
ID            NAME            REPLICAS  IMAGE              COMMAND
794lmhdqvj0d  dreamy_euler    1/1       ppc64le/mysql
eh1zbktxdrcq  jovial_carson   1/1       ppc64le/mysql

# docker service ps eh1zbktxdrcq
ID                         NAME             IMAGE          NOD           DESIRED STATE  CURRENT STATE          ERROR
79n3sww7zzrlhk7l3arrz8fpw  jovial_carson.1  ppc64le/mysql  pkb-rhel71-2  Running        Running 30 seconds ago

Similarly, you can add labels to a swarm node and use the labels for scheduling.

# docker node update --label-add role=frontend pkb-rhel71-3
# docker node inspect pkb-rhel71-3 --pretty
ID:			9bck58xolilxic1b188ae1kac
 - role = frontend
Hostname:		pkb-rhel71-3
 State:			Ready
 Availability:		Active
 Operating System:	linux
 Architecture:		ppc64le
 CPUs:			2
 Memory:		11.47 GiB
  Network:		bridge, host, null, overlay
  Volume:		local
Engine Version:		1.12.0

# docker service create --constraint 'node.labels.role==frontend'  ppc64le/mysql

As you can see, setting up a Docker cluster using the new Docker Swarm mode is a breeze – just two commands and you have a working cluster. Ofcourse for a production deployment there will be multiple add-on steps, however the simplicity of the initial setup cannot be ignored. Kubernetes have also adopted similar mechanism for initial cluster setup. Check out this article for more detail –

[This article appeared first at – ]


Pradipta Kumar Banerjee

I'm a Cloud and Linux/ OpenSource enthusiast, with 16 years of industry experience at IBM. You can find more details about me here - Linkedin

You may also like...