docker icon indicating copy to clipboard operation
docker copied to clipboard

Can't change the name of the "master" node in docker-compose.yml

Open butla opened this issue 5 years ago • 2 comments

I'm integrating your docker-compose.yml (the setup with one worker, that is) into mine. I've noticed that changing the service name of "master" causes the setup to fail.

YML with "master" changed to "citus_master":

version: '2.1'

services:
  citus_master:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_master"
    image: 'citusdata/citus:7.4.1'
    ports: ["${MASTER_EXTERNAL_PORT:-5432}:5432"]
    labels: ['com.citusdata.role=Master']
  worker:
    image: 'citusdata/citus:7.4.1'
    labels: ['com.citusdata.role=Worker']
    depends_on: { manager: { condition: service_healthy } }
  manager:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_manager"
    image: 'citusdata/membership-manager:0.2.0'
    volumes: ['/var/run/docker.sock:/var/run/docker.sock']
    depends_on: { citus_master: { condition: service_healthy } }

docker-compose up; docker-compose down -v output:

Creating network "XXX_default" with the default driver
Creating citus_master ... done
Creating citus_manager ... done

ERROR: for worker  Container "552289a87b71" is unhealthy.
ERROR: Encountered errors while bringing up the project.
Stopping citus_manager ... done
Stopping citus_master  ... done
Removing citus_manager           ... done
Removing citus_master            ... done
Removing XXX_worker_1 ... done
Removing network XXX_default

Are there some hardcodes somewhere, that are causing this? Should I pass some other option when I change the name of the service?

butla avatar Jul 19 '18 09:07 butla

Can you try setting the environment variable CITUS_HOST to your new name for the citus_manager service?

jasonmp85 avatar Jul 19 '18 19:07 jasonmp85

@jasonmp85 Yup, that works. It's be good to convey that info in the Compose file. I see two options:

version: '2.1'

services:
  master:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_master"
    image: 'citusdata/citus:7.4.1'
    ports: ["${MASTER_EXTERNAL_PORT:-5432}:5432"]
    labels: ['com.citusdata.role=Master']
  worker:
    image: 'citusdata/citus:7.4.1'
    labels: ['com.citusdata.role=Worker']
    depends_on: { manager: { condition: service_healthy } }
  manager:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_manager"
    image: 'citusdata/membership-manager:0.2.0'
    volumes: ['/var/run/docker.sock:/var/run/docker.sock']
    depends_on: { master: { condition: service_healthy } }
    environment:
      - CITUS_HOST=master

or

version: '2.1'

services:
  # If you change the name of this service you need to set CITUS_HOST in manager's environment to it.
  master:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_master"
    image: 'citusdata/citus:7.4.1'
    ports: ["${MASTER_EXTERNAL_PORT:-5432}:5432"]
    labels: ['com.citusdata.role=Master']
  worker:
    image: 'citusdata/citus:7.4.1'
    labels: ['com.citusdata.role=Worker']
    depends_on: { manager: { condition: service_healthy } }
  manager:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_manager"
    image: 'citusdata/membership-manager:0.2.0'
    volumes: ['/var/run/docker.sock:/var/run/docker.sock']
    depends_on: { master: { condition: service_healthy } }

What do you think? I can make the PR.

butla avatar Jul 22 '18 20:07 butla