Installing Docker Swarm on Fedora CoreOS Latest
Prerequisites
- A running instance of Fedora CoreOS Latest with SSH access.
- Basic knowledge of Docker and Swarm.
Step 1: Install Docker on Fedora CoreOS
Before installing Docker Swarm, you need to install Docker on Fedora CoreOS. Follow the below instructions to do that:
Connect to your Fedora CoreOS instance via SSH.
Run the following command to install Docker:
sudo yum install docker
- Start and enable Docker with the following commands:
sudo systemctl start docker
sudo systemctl enable docker
- Check if Docker is running by entering the following command:
sudo systemctl status docker
Step 2: Initialize Docker Swarm
Once you have installed Docker, you need to initialize the Docker Swarm. Follow the below instructions to do that:
- Start Docker Swarm with the following command:
sudo docker swarm init
- You should see output similar to the following:
Swarm initialized: current node (dqg556dtcyt1n8t2cmrf9mvnw) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-0hh2gxxxxxxxxxxxxxxxxx 192.168.99.101:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
- Note down the token that is displayed in the output as you will need it to join other nodes to the Swarm.
Step 3: Deploy Your First Service
Now that you have initialized Docker Swarm, you can deploy your first service. Follow the below instructions to do that:
- Create an NGINX service with the following command:
sudo docker service create --replicas 3 --name nginx-service nginx
- Check the status of the service with the following command:
sudo docker service ls
- You should see output similar to the following:
ID NAME MODE REPLICAS IMAGE PORTS
lh2js8vtq3r3 nginx-service replicated 3/3 nginx:latest
Step 4: Scaling Your Services
One of the main benefits of Docker Swarm is the ability to scale services up and down. Follow the below instructions to scale your services:
- Scale up the NGINX service to 5 replicas with the following command:
sudo docker service scale nginx-service=5
- Check the status of the service with the following command:
sudo docker service ls
- You should see output similar to the following:
ID NAME MODE REPLICAS IMAGE PORTS
lh2js8vtq3r3 nginx-service replicated 5/5 nginx:latest
Conclusion
In this tutorial, you have learned how to install Docker Swarm on Fedora CoreOS and deploy and scale services. You can now experiment with deploying different services and scaling them to meet your needs.