Docker: Difference between `docker run` and `docker service`

CuriousMind picture CuriousMind · Oct 9, 2017 · Viewed 8k times · Source

I am very new to docker , just started venturing into this. I read online about this. I came to know of the following commands of docker which is: docker run and docker service. As I understood , with docker run we are spinning a new container. However I am not clear what docker service do? Does it spin container in a Swarm?

Can anyone help understand in simple to understand?

Answer

BMitch picture BMitch · Oct 9, 2017

The docker run command creates and starts a container on the local docker host.

A docker "service" is one or more containers with the same configuration running under docker's swarm mode. It's similar to docker run in that you spin up a container. The difference is that you now have orchestration. That orchestration restarts your container if it stops, finds the appropriate node to run the container on based on your constraints, scale your service up or down, allows you to use the mesh networking and a VIP to discover your service, and perform rolling updates to minimize the risk of an outage during a change to your running application.