Different pieces of the app are called “services” For example, a service for storing application data in a database, a service for the front-end, etc.
Services are just “containers in production.” A service only runs one image, but it manages for example what ports it should use and how many replicas of the container should run.
To define a service, you'll need an
Here you define the image to be loaded, how many replicas, the resource limits and the restart conditions.
To run it you must first start:
docker swarm init
Then run it giving a name:
docker stack deploy -c docker-compose.yml <app_name>
To see the details of containers running in your service, run:
docker stack ps <app_name>
Now each time you request your app (via browser, for example), the load-balancer will help you distributing the requests to each replica.
To put it down,
docker stack rm <app_name>
This puts down the app, but not the "one-node" swarm we created. Use:
docker swarm leave --force