Using 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:

What you'll need

For IBM® 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, if you want to try out the latest upstream Docker binary on IBM Power Systems™ servers, you can download it 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.

Some key terms


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.

Setting up a swarm cluster

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

Step 1. 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
                ID                           HOSTNAME         STATUS        AVAILABILITY MANAGER STATUS
                0gqevumsltdkz8bo8a4ybprii*   pkb-rhel71-1     Ready         Active       Leader
                0snc3k2kuwdgx2obijvvf3zvq    pkb-rhel71-2     Ready         Active 
                9bck58xolilxic1b188ae1kac    pkb-rhel71-3     Ready         Active

Step 2: 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
                # dockerservice 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
                       "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 3: 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         NODE          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.

Downloadable resources


Sign in or register to add and subscribe to comments.

ArticleTitle=Using Docker Swarm mode on OpenPOWER servers