Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between docker service and stack?

I am wondering what the difference between such things. They have got almost the same commands and give the same result.

like image 459
Dmytro Nalyvaiko Avatar asked Jun 02 '17 12:06

Dmytro Nalyvaiko


People also ask

What is a stack in docker?

Docker Stack is run across a Docker Swarm, which is essentially a group of machines running the Docker daemon, which are grouped together, essentially pooling resources. Stacks allow for multiple services, which are containers distributed across a swarm, to be deployed and grouped logically.

What is a docker service?

Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime.

What is the difference between docker compose and docker stack?

Docker Compose is an official tool that helps you manage your Docker containers by letting you define everything through a docker-compose. yml file. docker stack is a command that's embedded into the Docker CLI. It lets you manage a cluster of Docker containers through Docker Swarm.

What is difference between service and container?

Services and container are related but both are different things. A service can be run by one or multiple containers. With docker you can handle containers and with docker-compose you can handle services. This compose file defines two services, web and db .


2 Answers

The docker service is used when managing individual service on a docker swarm cluster. It is the client command line to access the docker swarm manager.

The docker stack can be used to manage a multi-service application. It also moves many of the options you would enter on the docker service into the .yml file (such as docker-cloud.yml or docker-compose.yml) for easier reuse. It works as a front end "script" on top of the docker swarm manager used by docker swarm cluster, so you can do everything docker stack does with docker service.

Last but not least, you can consider the docker service vs docker stack is the same as docker run vs docker compose, but in the docker swarm cluster.

like image 95
benjah1 Avatar answered Sep 20 '22 19:09

benjah1


A Service defines one or more instances of a single image deployed on one or more machines (described by one entry in the services part of the docker-compose.yaml files).

A Stack defines a group of heterogeneous services (described by the whole yaml file).

like image 31
demented hedgehog Avatar answered Sep 23 '22 19:09

demented hedgehog