Home > Back-end >  Deploy docker to separate hosts using docker componse
Deploy docker to separate hosts using docker componse

Time:10-02

How can I use docker-compose to deploy containers in separate hosts and servers?

Is it even possible?

CodePudding user response:

Yes, with docker swarm mode. Read more: https://docs.docker.com/engine/swarm/

You can schedule your containers with labels in your compose:

version: "2"
services:
  foo:
    image: foo
    volumes_from: ["bar"]
    network_mode: "service:baz"
    labels:
      - "constraint:node==node-1" # Schedule containers on a specific node
  bar:
    image: bar
    labels:
      - "constraint:node==node-1"
  baz:
    image: baz
    labels:
      - "constraint:node==node-1"
  • Related