docker_swarm_configuration

ubuntu@ip-172-31-10-78:~$ docker swarm init
Swarm initialized: current node (pofc9eu8fpza7kkwmbn97lsco) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-2i7ry795oigvvjsnqfl37nb2d27v2bn3gasxpkymlzjlils1mk-0csdkdsh9uw4j9y1kvbg4esqt 172.31.10.78:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
==================================
172-31-10-78: Master
172-31-10-222:worker

ubuntu@ip-172-31-10-222:~$ docker swarm join --token SWMTKN-1-2i7ry795oigvvjsnqfl37nb2d27v2bn3gasxpkymlzjlils1mk-0csdkdsh9uw4j9y1kvbg4esqt 172.31.10.78:2377
This node joined a swarm as a worker.

ubuntu@ip-172-31-10-222:~$ docker node ls   ("this comamnd will work on only master noide")
Error response from daemon: This node is not a swarm manager. Worker nodes can't be used to view or modify cluster state. Please run this command on a manager node or promote the current node to a manager.

==================================
ubuntu@ip-172-31-10-78:~$ docker node ls ("before worker added to master node")
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
pofc9eu8fpza7kkwmbn97lsco *   ip-172-31-10-78     Ready               Active              Leader              18.06.1-ce

ubuntu@ip-172-31-10-78:~$ docker node ls  ("after worker added to master node")
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
pofc9eu8fpza7kkwmbn97lsco *   ip-172-31-10-78     Ready               Active              Leader              18.06.1-ce
w16shakfd1t55oovfs0qlbolr     ip-172-31-10-222    Ready               Active                                  18.06.1-ce
ubuntu@ip-172-31-10-78:~$

==================================
"overlay driver" will appear after your swarm init command:
---------------------------------------
MASTER:
Before:
-------
ubuntu@ip-172-31-10-78:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
dfead07f53ae        bridge              bridge              local
bb2cf51faa00        host                host                local
425d8a9dc6fe        none                null                local

After:(Swarm)
------------

ubuntu@ip-172-31-10-78:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
dfead07f53ae        bridge              bridge              local
f19113c010e7        docker_gwbridge     bridge              local
bb2cf51faa00        host                host                local
yq1qytewkl7u        ingress             overlay             swarm
425d8a9dc6fe        none                null                local

WORKER:
Before:
-------
ubuntu@ip-172-31-10-222:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
559605f2995c        bridge              bridge              local
aa19f2b9b9e5        host                host                local
23a6a49c62f2        none                null                local


ubuntu@ip-172-31-10-222:~$ docker swarm join --token SWMTKN-1-2i7ry795oigvvjsnqfl37nb2d27v2bn3gasxpkymlzjlils1mk-0csdkdsh9uw4j9y1kvbg4esqt 172.31.10.78:2377
This node joined a swarm as a worker.

After:(join to master)
------------
ubuntu@ip-172-31-10-222:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
559605f2995c        bridge              bridge              local
9fc9c33168a2        docker_gwbridge     bridge              local
aa19f2b9b9e5        host                host                local
yq1qytewkl7u        ingress             overlay             swarm
23a6a49c62f2        none                null                local
=======================
cretae own overlay network at master node:
--------------------------------------------
ubuntu@ip-172-31-10-78:~$ docker network create -d overlay qt-ganesh
yq7g57jiz4qt5qsbkedjp8ze5
ubuntu@ip-172-31-10-78:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
dfead07f53ae        bridge              bridge              local
f19113c010e7        docker_gwbridge     bridge              local
bb2cf51faa00        host                host                local
yq1qytewkl7u        ingress             overlay             swarm
425d8a9dc6fe        none                null                local
yq7g57jiz4qt        qt-ganesh           overlay             swarm
ubuntu@ip-172-31-10-78:~$

Note: This service will not visable at worker node until you create container.

=============================
Pull jenkins images:

ubuntu@ip-172-31-10-78:~$ docker pull jenkins/jenkins

ubuntu@ip-172-31-10-78:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
jenkins/jenkins     latest              b1ddaeaa38a3        3 days ago          701MB


===========================
Docker jenkin service creation with  own network:
------------------------------------------------------

ubuntu@ip-172-31-10-78:~$ docker service create --name jenkin-ganesh-svc9 --network qt-ganesh --replicas 2 jenkins/jenkins
hyuh03f91nmwjb1wx6mm44wtn
overall progress: 2 out of 2 tasks
1/2: running   [==================================================>]
2/2: running   [==================================================>]
verify: Service converged


========================================
check servcies:
--------------
Before service creation:
---------------------------
ubuntu@ip-172-31-10-78:~$ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS


ubuntu@ip-172-31-10-78:~$ docker service create --name jenkin-ganesh-svc9 --network qt-ganesh --replicas 2 jenkins/jenkins
hyuh03f91nmwjb1wx6mm44wtn
overall progress: 2 out of 2 tasks
1/2: running   [==================================================>]
2/2: running   [==================================================>]
verify: Service converged

After service creation:
---------------------------
ubuntu@ip-172-31-10-78:~$ docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE                    PORTS
hyuh03f91nmw        jenkin-ganesh-svc9   replicated          2/2                 jenkins/jenkins:latest

========================================
check jenkin container has been cretaed or not on both master and nodes:
------------------------------------------------------------------------
Master:
-------
ubuntu@ip-172-31-10-78:~$ docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS              PORTS                 NAMES
dd91c752b84b        jenkins/jenkins:latest   "/sbin/tini -- /usr/…"   About a minute ago   Up About a minute   8080/tcp, 50000/tcp   jenkin-ganesh-svc9.1.f1ww9bailriot9ovxtq50quon

Node:
-------
ubuntu@ip-172-31-10-222:~$ docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS              PORTS                 NAMES
55cbdc0b4bc0        jenkins/jenkins:latest   "/sbin/tini -- /usr/…"   About a minute ago   Up About a minute   8080/tcp, 50000/tcp   jenkin-ganesh-svc9.2.at23wmt12c7x3bdgnrfvtg89i

ubuntu@ip-172-31-10-222:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
559605f2995c        bridge              bridge              local
9fc9c33168a2        docker_gwbridge     bridge              local
aa19f2b9b9e5        host                host                local
yq1qytewkl7u        ingress             overlay             swarm
23a6a49c62f2        none                null                local
yq7g57jiz4qt        qt-ganesh           overlay             swarm


=============================================

check service inspect :(Only it will work on master)
----------------------------------

ubuntu@ip-172-31-10-78:~$ docker service inspect hyuh03f91nmw
[
    {
        "ID": "hyuh03f91nmwjb1wx6mm44wtn",
        "Version": {
            "Index": 4116
        },
        "CreatedAt": "2018-10-26T12:20:29.131590669Z",
        "UpdatedAt": "2018-10-26T12:20:29.132707078Z",
        "Spec": {
            "Name": "jenkin-ganesh-svc9",
            "Labels": {},
            "TaskTemplate": {
                "ContainerSpec": {
                    "Image": "jenkins/jenkins:latest@sha256:5d9450a3b391e96a1525f6a5b40b3e2095df7a19195b6341fb097120cb0ab099",
                    "Init": false,
                    "StopGracePeriod": 10000000000,
                    "DNSConfig": {},
                    "Isolation": "default"
                },
                "Resources": {
                    "Limits": {},
                    "Reservations": {}
                },
                "RestartPolicy": {
                    "Condition": "any",
                    "Delay": 5000000000,
                    "MaxAttempts": 0
                },
                "Placement": {
                    "Platforms": [
                        {
                            "Architecture": "amd64",
                            "OS": "linux"
                        }
                    ]
                },
                "Networks": [
                    {
                        "Target": "yq7g57jiz4qt5qsbkedjp8ze5"
                    }
                ],
                "ForceUpdate": 0,
                "Runtime": "container"
            },
            "Mode": {
                "Replicated": {
                    "Replicas": 2
                }
            },
            "UpdateConfig": {
                "Parallelism": 1,
                "FailureAction": "pause",
                "Monitor": 5000000000,
                "MaxFailureRatio": 0,
                "Order": "stop-first"
            },
            "RollbackConfig": {
                "Parallelism": 1,
                "FailureAction": "pause",
                "Monitor": 5000000000,
                "MaxFailureRatio": 0,
                "Order": "stop-first"
            },
            "EndpointSpec": {
                "Mode": "vip"
            }
        },
        "Endpoint": {
            "Spec": {
                "Mode": "vip"
            },
            "VirtualIPs": [
                {
                    "NetworkID": "yq7g57jiz4qt5qsbkedjp8ze5",
                    "Addr": "10.0.0.102/24"
                }
            ]
        }
    }
]
ubuntu@ip-172-31-10-78:~$

====================
Add node to master:
Note : One new node before join need to install docker:
======
node2: ubuntu@ip-172-31-32-98:~$ docker swarm join --token SWMTKN-1-2i7ry795oigvvjsnqfl37nb2d27v2bn3gasxpkymlzjlils1mk-0csdkdsh9uw4j9y1kvbg4esqt 172.31.10.78:2377
This node joined a swarm as a worker.

Before new node:
-----------------
ubuntu@ip-172-31-10-78:~$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
pofc9eu8fpza7kkwmbn97lsco *   ip-172-31-10-78     Ready               Active              Leader              18.06.1-ce
w16shakfd1t55oovfs0qlbolr     ip-172-31-10-222    Ready               Active                                  18.06.1-ce

after new node:
----------------
ubuntu@ip-172-31-10-78:~$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
pofc9eu8fpza7kkwmbn97lsco *   ip-172-31-10-78     Ready               Active              Leader              18.06.1-ce
w16shakfd1t55oovfs0qlbolr     ip-172-31-10-222    Ready               Active                                  18.06.1-ce
ucpln95yqyuj39olns316letk     ip-172-31-32-98     Ready               Active                                  18.06.1-ce
ubuntu@ip-172-31-10-78:~$

Comments

Popular posts from this blog

How to run Jenkins on Docker container | How to create Jenkins Volumes on Docker

POWERSHELL

Building game of life container