Introduction to Docker Swarm -Part 2

Nikhil Patil
2 min readSep 15, 2020

--

Service:

Run the command below from the manager node only:

docker service create — name myhttpd — replicas 1 -p 18080:80 httpd

v17zrxurtjq6tqhc5htcrnjuu
overall progress: 1 out of 1 tasks
1/1: running [=====================================>]
verify: Service converged

  • The docker service create command creates the service.
  • The — name flag names the service myhttpd.
  • The — replicas flag specifies the desired state of 1 running instance.
  • The argument httpd define the service as an httpd container.

List of running services.

docker service ls

The following command shows all the tasks that are part of the myhttpd service

docker service ps myhttpd

Scaling Swarm Servic:- The scale command enables you to scale one or more replicated services either up or down to the desired number of replicas

docker service scale myhttpd=5

If you again check the list of tasks for that particular service

docker service ps myhttpd

The same way we scale up service, we can scale it down

docker service scale myhttpd=3

To verify it

docker service ps myhttpd

Thank You!!!

--

--