1
00:00:00,000 --> 00:00:09,840
In this video, you'll get a quick introduction to Docker Swarm.

2
00:00:09,840 --> 00:00:11,200
So what is Docker Swarm?

3
00:00:11,200 --> 00:00:17,400
Well, it's a Docker solution to create a cluster or a swarm of multiple Docker hosts.

4
00:00:17,400 --> 00:00:21,000
It's doing what Kubernetes is doing, basically.

5
00:00:21,000 --> 00:00:25,280
Before Docker 20, Docker Enterprise Edition was needed to use Swarm.

6
00:00:25,280 --> 00:00:30,820
But since Docker 20, Docker Swarm is open source and free and doesn't require any license.

7
00:00:30,820 --> 00:00:34,139
So you can easily take it for a test drive.

8
00:00:34,139 --> 00:00:38,779
Docker Swarm allows for handling of container scheduling, scaling, networking, and failover

9
00:00:38,779 --> 00:00:39,779
automatically.

10
00:00:39,779 --> 00:00:44,139
And you can see it as an easier alternative to Kubernetes.

11
00:00:44,139 --> 00:00:47,860
It's not as feature rich, but it's pretty easy to get started.

12
00:00:47,860 --> 00:00:52,000
In order to work with Docker Swarm, you need to be familiar with the terminology.

13
00:00:52,000 --> 00:00:56,820
So a swarm refers to the entire cluster, which is a group of Docker nodes.

14
00:00:56,820 --> 00:01:01,759
And nodes are the Docker hosts that are used either as a manager, which controls, or as

15
00:01:01,759 --> 00:01:05,279
a worker, which runs user workloads.

16
00:01:05,279 --> 00:01:07,699
A service is the description of what to run.

17
00:01:07,699 --> 00:01:12,879
And that includes a container image, ports, replicas, and constraints, where replicas

18
00:01:12,879 --> 00:01:17,279
can be multiple instances of the same container image.

19
00:01:17,279 --> 00:01:20,720
A task is a specific container that runs in a service.

20
00:01:20,720 --> 00:01:25,519
And a stack is a collection of services that makes up a microservice application.

21
00:01:25,519 --> 00:01:29,419
To work with Docker Swarm, you need to know about a couple of commands.

22
00:01:29,419 --> 00:01:31,320
They all start with Docker Swarm.

23
00:01:31,320 --> 00:01:35,000
And Docker Swarm init creates a cluster on the first node.

24
00:01:35,000 --> 00:01:38,720
Docker Swarm join allows other nodes to join the cluster.

25
00:01:38,720 --> 00:01:43,139
And Docker node ls shows all the nodes in the Swarm cluster.

26
00:01:43,139 --> 00:01:49,980
Docker service create, minus minus name web, minus p 8080 colon 80, creates a service based

27
00:01:49,980 --> 00:01:56,360
on the nginx container image and is providing port forwarding to it using port 80.

28
00:01:56,360 --> 00:02:01,620
Docker service scale, web is five, scales the web service to five running instances.

29
00:02:01,620 --> 00:02:05,940
And Docker service ls gives a list of services and their replica count.

30
00:02:05,940 --> 00:02:08,139
Docker stack deploy is a very useful command.

31
00:02:08,139 --> 00:02:11,800
It deploys a stack as defined in a compose file.

32
00:02:11,800 --> 00:02:16,960
And Docker service logs gives output generated by all containers in a service.

33
00:02:16,960 --> 00:02:19,399
Let me give you a quick demo.

34
00:02:19,399 --> 00:02:26,240
So I'm starting with my Docker Swarm init.

35
00:02:26,240 --> 00:02:29,160
And that is making that this node is now a manager.

36
00:02:29,160 --> 00:02:31,880
As you can see, it's printing a join command.

37
00:02:31,880 --> 00:02:38,600
And the join command is what you can use on other nodes to add them to the Swarm cluster.

38
00:02:38,600 --> 00:02:43,000
And once you're done building your Swarm cluster, you use Docker service create, minus

39
00:02:43,000 --> 00:02:51,720
minus name web, minus p 80 colon 80, nginx for instance.

40
00:02:51,720 --> 00:02:57,559
And as you can see, that is creating the service for you.

41
00:02:57,559 --> 00:03:03,559
Now Docker service scale is what you can use to add some scalability.

42
00:03:03,559 --> 00:03:08,880
So let's do a Docker service scale, web is five, to ensure that it's using five different

43
00:03:08,880 --> 00:03:10,559
instances.

44
00:03:10,559 --> 00:03:15,759
And then Docker service ls is showing that the service is now running.

45
00:03:15,759 --> 00:03:18,059
And we have five different replicas on it.

46
00:03:18,059 --> 00:03:20,059
So it is ready for business.

47
00:03:20,059 --> 00:03:21,720
And that's enough about Docker Swarm.

48
00:03:21,720 --> 00:03:24,919
Because after all, Docker Swarm is a topic all by itself.

49
00:03:24,919 --> 00:03:27,160
And you just need to know a little bit about it.

50
00:03:27,160 --> 00:03:28,000
This should be enough.

