DevOps, Project Blog - 4

DevOps, Project Blog - 4

Project

  1. Launch 3 instances, 1-manager, other 2-workers, and SSH it...

  2. Set up Docker: Install Docker in all the instances, and check the version..

     sudo apt install docker.io
     docker -v
    
  3. Initialize a Docker Swarm:

    On a manager instance, initialize a Docker Swarm cluster by running the following command:

     docker swarm init
    

    This command will provide you with a token that you can use to join worker nodes to the swarm.

  4. Enable the 2377 port in all the instances...

  5. Join Worker Nodes:

    On each worker instance, run the following command and replace <manager-ip> with the IP address of your manager node and <token> with the token provided in the previous step:

     docker swarm join --token <token> <manager-ip>:2377
    

    copy this and paste it into both worker instances

    This will add the worker node to the Docker Swarm cluster.

  6. List the nodes (both manager and worker nodes) in your Docker Swarm cluster

  7. To deploy the application on the Docker Swarm servers, let's pull an image from my repository.

  8. Create a service on the Docker manager node server to install the application using the Docker image from Docker Hub.

     sudo docker service create --name <service-name> --replicas <number-of-replicas> --publish <published-port>:<target-port> <image-name>:<image-tag>
    

  9. Check the running containers in all the instances.

     sudo docker ps
    

  10. Now to access our application in the browser, we need to enable the destination port.

    Edit inbound rules and allow 8000 port in all the instances

  11. Now, we can access the application on each instance by specifying the respective port number.

    • Manager instance

    • worker-1 instance

    • worker-2 instance


Thank you so much for reading

Follow me on LinkedIn to see interesting posts like this : )

Linkedin

Β