Create a Docker Swarm playground
Docker Swarm, a lightweight container orchestrator, provides an excellent way to manage containerized applications. In this blog post, we’ll explore how to set up and run Docker Swarm on your local machine. This guide will help you get started.
Why Run Docker Swarm Locally?
- Easy Testing: With a local setup, you can experiment with Docker Swarm features without worrying about breaking anything in a production environment.
- Fear-Free Environment: No need to fear accidental misconfigurations or service disruptions. Your local setup is isolated and safe.
- Testing and Demos: Use Docker Swarm for testing your applications or showcasing demos during presentations.
- Simplicity: Compared to Kubernetes, Docker Swarm offers a simpler and more straightforward orchestration experience.
Architecture
Loading graph...
Setup
Below is the Docker Compose file that sets up one manager and three worker nodes for your Docker Swarm:
Next, you’ll find an initialization script that sets up the infrastructure, creates a Docker Swarm cluster, and adds the workers to this Swarm.
Lastly, you can incorporate a visualizer application to observe the cluster:
To run the visualizer using Docker Compose, execute docker stack deploy --compose-file visualizer.yml visualize
inside the manager, wait for completion, and then visit localhost:8000
to check your cluster.
Examples
Here are some docker-compose
examples you can use to check if your containers are well deployed in the Swarm cluster.
Nginx application
NodeJS and Mongo application
Note: You may need to add these lines in to Dockerfile to make it work (original: https://hub.docker.com/layers/nanajanashia/k8s-demo-app/v1.0/images/sha256-6f554135da39ac00a1c2f43e44c2b0b54ca13d3d8044da969361e7781adb7f95?context=explore):
Traefik
Conclusion
By following this guide, you should now be able to set up and run Docker Swarm on your local machine. Happy containerizing! 😊
The SOLID/STUPID principles
Learn what are the SOLID and STUPID principles with examples
Setup a Kubernetes cluster with K3S, Traefik, CertManager and Kubernetes Dashboard
Let's setup step by step our own K3S cluster !
Create an Ansible playground with Docker
Let's create an Ansible playground with Docker
Database ACID/BASE - Understanding the CAP Theorem
Learn what is the CAP Theorem in less than 5 minutes !
HashiCorp Vault - Technological watch
Learn what is HashiCorp Vault in less than 5 minutes !
How to internationalize an AstroJS website while maintaining good SEO ?
We will see how to create an implementation of i18n with AstroJS
Remember all the commands of a project with Makefile
We will see how to remember all command of a project & write documentation with Makefile !
LFTP - Deploy an application in command line
Here we will see how to automatically deploy an application with lftp in command line.