What is the difference between Docker Service and Docker Container?

前端 未结 5 2056
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 19:04

When do we use a docker service create command and when do we use a docker run command?

5条回答
  •  清酒与你
    2020-12-23 19:33

    • docker run is used to create a standalone container
    • docker service create is used to create instances (called tasks) of that service running in a cluster (called swarm) of computers (called nodes). Those tasks are containers of cource, but not standalone containers. In a sense a service acts as a template when instantiating tasks.

    For example

    docker service create --name MY_SERVICE_NAME --replicas 3 IMAGE:TAG
    

    creates 3 tasks of the MY_SERVICE_NAME service, which is based on the IMAGE:TAG image.

    More information can be found here

提交回复
热议问题