Build Your Own AI Assistant Part 1 - Creating the Assistant
116316 Views
Is the new Raspberry Pi AI Kit better than Google Coral?
111570 Views
Control Arduino with Python using Firmata / PyFirmata
86865 Views
How to Map with LiDAR - using a Raspberry Pi Zero 2W, RPLidar and Rviz
56603 Views
Creating a Supercomputer with a Raspberry Pi 5 Cluster and Docker Swarm!
52712 Views
Node-Red Automation, MQTT, NodeMCU & MicroPython
51798 Views
Weather Station Display
Pi 10 Inch Mini-rack
Installing and Using DeepSeek-R1:1.5 on a Raspberry Pi with Docker
Gamepad & BurgerBot
Level Up your CAD Skills
Operation Pico
Mini-Rack 3D Design Tutorial
0h 20m
Using the Raspberry Pi Pico's Built-in Temperature Sensor
0h 24m
Getting Started with SQL
0h 32m
Introduction to the Linux Command Line on Raspberry Pi OS
0h 42m
How to install MicroPython
0h 8m
Wall Drawing Robot Tutorial
0h 22m
Learn Linux from the basics to advanced topics.
Learn how to use a Raspberry Pi Pico
Learn MicroPython the best language for MicroControllers
Learn Docker, the leading containerization platform. Docker is used to build, ship, and run applications in a consistent and reliable manner, making it a popular choice for DevOps and cloud-native development.
Learn how to build SMARS robots, starting with the 3D Printing the model, Designing SMARS and Programming SMARS
Learn how to build robots, starting with the basics, then move on to learning Python and MicroPython for microcontrollers, finally learn how to make things with Fusion 360.
Learn Python, the most popular programming language in the world. Python is used in many different areas, including Web Development, Data Science, Machine Learning, Robotics and more.
Learn how to create robots in 3D, using Fusion 360 and FreeCAD. The models can be printed out using a 3d printer and then assembled into a physical robot.
Learn how to create Databases in Python, with SQLite3 and Redis.
KevsRobots Learning Platform
42% Percent Complete
By Kevin McAleer, 5 Minutes
Deploying applications on a Docker Swarm cluster requires understanding the tools available for managing service configurations and orchestrations. This lesson introduces Docker Compose and Swarm Stacks, explaining their purposes, differences, and how to use them effectively in a Swarm environment.
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services, networks, and volumes. Then, with a single command, you create and start all the services defined in your configuration.
Swarm Stacks are similar to Docker Compose but are specifically designed for managing applications across a Docker Swarm cluster. Stacks allow you to deploy, update, and scale services across multiple Docker hosts within the Swarm.
docker-compose up
docker stack deploy
docker-compose.yml
Deploy the Stack:
Run the following command on a manager node to deploy the stack:
docker stack deploy -c docker-compose.yml <STACK_NAME>
Replace <STACK_NAME> with a name for your stack.
<STACK_NAME>
Check the status of your stack with:
docker stack services <STACK_NAME>
This command lists the services in your stack, along with their replicas and status.
You may often need to update docker services with the latest version of a container. One of quirks of docker is that it does not automatically update the containers to the latest version, when you do docker service update <SERVICENAME>. You need to follow the process below, in this example a service called kevsrobots is updated to the latest version.
docker service update <SERVICENAME>
kevsrobots
Build (or Rebuild) and tag the image
docker build -t 192.168.2.1:5000/kevsrobots:latest .
Push the image After rebuilding your image, tag it (even if you’re reusing the latest tag) and push it to the registry.
docker push 192.168.2.1:5000/kevsrobots:latest
Update the Service To update the service and force all nodes to pull the latest image, use the –image flag with the docker service update command, specifying the full image name, including the tag:
docker service update --image 192.168.2.1:5000/kevsrobots:latest kevsrobots
Force Pull: If you want to explicitly ensure that Docker Swarm pulls the image on each node, you can use the –with-registry-auth flag to pass registry authentication credentials to the Swarm nodes. This is particularly useful if your image is stored in a private registry that requires authentication.
docker service update --image 192.168.2.1:5000/kevsrobots:latest --with-registry-auth kevsrobots
No Downtime: Ensure you have configured the service with an appropriate update policy to achieve zero downtime deployments. You can set parameters like –update-parallelism and –update-delay to control the rollout of the update across the service’s tasks.
docker service update --image 192.168.2.1:5000/kevsrobots:latest --update-parallelism 1 --update-delay 10s kevsrobots
Rollback Strategy: It’s also a good practice to configure a rollback strategy in case the new version of the image introduces issues.
docker service update --image 192.168.2.1:5000/kevsrobots:latest --rollback-parallelism 1 --rollback-delay 10s kevsrobots
By following these steps, you can ensure that all nodes in your Docker Swarm pull and use the latest version of your image, maintaining the consistency of your deployment.
Docker Compose and Swarm Stacks provide powerful and flexible tools for deploying and managing containerized applications. Understanding when and how to use each tool is crucial for effectively managing your Docker Swarm cluster. By leveraging Docker Stacks, you can take full advantage of Docker Swarm’s capabilities for deploying scalable and resilient applications across multiple nodes in your cluster.
< Previous Next >