T
T
TitanFighter2017-02-04 01:01:37
Docker
TitanFighter, 2017-02-04 01:01:37

How can I deploy a project on 2 servers (some applications on the 1st server, some on the 2nd) using Docker Compose?

I have something like this docker-compose.yml config, which currently runs all applications on the same server:

version: '2'
services:
  nginx:
    image: nginx:latest
    ports:
      - "80:80"

    volumes:
      - ./dockerfiles/nginx:/etc/nginx/conf.d
      - ../static:/static
      - ../media:/media

    depends_on:
      - web

  web:
    build: ./dockerfiles/web/
    command: bash -c 'uwsgi --ini ./settings/uwsgi_conf.ini'

    depends_on:
      - db
      - solr-docker
      - redis-docker
      - celery

    volumes:
      - ./web:/web
      - ../static:/static
      - ../media:/media

  solr-docker:
    image: solr:latest

    volumes:
      - ./dockerfiles/solr/default:/opt/solr/server/solr/mycores/default

  db:
    image: postgres:latest

I want to take out Solr on the 2nd server. After reading articles on this issue, where it is proposed to use the Docker Machine + Swarm + Compose bundle, a mess has formed in my head. Is there any way to make everything easier?
Found a suggestion on stackoverflows to use extra_hosts:
solr-docker:
    image: solr:latest

    volumes:
      - ./dockerfiles/solr/default:/opt/solr/server/solr/mycores/default
    extra_hosts:
      - "solrhost:111.222.333.44"

But this option doesn't work. Maybe I don't cook it right. Maybe something needs to be done on the 2nd server (on which I want to run Solr)?
Compose is attractive because everything is configured in one file. If it is impossible to implement a project on several servers using Compose, how can this be done as simply as possible?
I would be grateful for advice and help on how to split the project into 2 servers.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
danforth, 2017-11-04
@danforth

I want to take out Solr on the 2nd server. After reading articles on this issue, where it is proposed to use the Docker Machine + Swarm + Compose bundle, a mess has formed in my head. Is there any way to make everything easier?

And what is porridge, in fact? Docker swarm + Docker compose deployment option to multiple servers.
There is a good guide here: https://docs.docker.com/get-started/part4/#introduction

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question