Victor96
Victor96

Reputation: 9572

Difference between Docker container and service

I'm wondering whether there are any differences between the following docker setups.

I'm wondering if you can administrate a swarm with the ability run a container on a specific node are there any use cases to have separate docker engines?

Upvotes: 2

Views: 588

Answers (1)

BMitch
BMitch

Reputation: 263637

The difference between the two is swarm mode. When a docker engine is running services in swarm mode you get:

  • Orchestration from the manager to continuously try to correct any differences between the current state and the target state. This can also include HA using the quorum model (as long as a majority of the managers are reachable to make decisions).
  • Overlay networking which allows containers on different hosts to talk to each other on their own container network. That can also involve IPSEC for security.
  • Mesh networking for published ports and a VIP for the service that doesn't change like container IP's do. The latter prevents problems from DNS caching. And the former has all nodes in the swarm publish the port and routes traffic to a container providing this service.
  • Rolling upgrades to avoid any downtime with replicated services.
  • Load balancing across multiple nodes when scaling up a service.

More details on swarm mode are available from docker's documentation.

The downside of swarm mode is that you are one layer removed from the containers when they run on a remote node. You can't run an exec command on a task to investigate a container, you need to do that on a container and be on the node it's currently using. Docker also removed some options from services like --volumes-from which don't apply when containers may be running on different machines.

If you think you may grow beyond running containers on a single node, need to communicate between the containers on different nodes, or simply want the orchestration features like rolling upgrades, then I would recommend swarm mode. I'd only manage containers directly on the hosts if you have a specific requirement that prevents swarm mode from being an option. And you can always do both, manage some containers directly and others as a service or stack inside of swarm, on the same nodes.

Upvotes: 4

Related Questions