How do I make unique hostname in case of scale up ?.
I did tried appending this {{.Config.Hostname}} but this does not work and gave error.
failed to create service docker-trino_trino-worker: Error response from daemon: rpc error: code = InvalidArgument desc = expanding hostname failed: template: expansion:1:41: executing "expansion" at <.Config.Hostname>: can't evaluate field Config in type *template.Context
For Service Trino-Worker, I need to have unique hostname when scaling up
hostname: "Trino-Worker-{{.Node.Hostname}}"
cat swarm-compose.yml
version: "3.8"
services:
hive-metastore:
build:
dockerfile: ../hive-metastore/Dockerfile
context: ../hive-metastore
image: 10.208.1.5:5000/hive-metastore:3.1.3
hostname: hivemetastore
networks:
trino-network-docker:
aliases:
- hivemetastore
environment:
- DATABASE_HOST=mysql-hivemeta.aws.com
- PROJECT_NAME=${COMPOSE_PROJECT_NAME}
ports:
- "9083:9083"
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
hiveservice2:
build:
dockerfile: ../hive/Dockerfile
context: ../hive
image: 10.208.1.5:5000/myhive:latest
networks:
- trino-network-docker
environment:
- DATABASE_HOST=mysql-hivemeta.aws.com
- PROJECT_NAME=${COMPOSE_PROJECT_NAME}
- IS_RESUME="TRUE"
- HIVE_CUSTOM_CONF_DIR=/hive_custom_conf
- DB_DRIVER=mysql
- HIVE_METASTORE_URI=${HIVE_METASTORE_URI}
- SERVICE_OPTS=-Dhive.metastore.uris=${HIVE_METASTORE_URI}
- VERBOSE="true"
- SERVICE_NAME=hiveserver2
volumes:
- ../hive/conf/:/hive_custom_conf
ports:
- "10000:10000"
- "10002:10002"
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
- hive-metastore
trino-master:
build:
dockerfile: ../trino/Dockerfile
context: ../trino
image: 10.208.1.5:5000/trinodb/trino:latest
hostname: trinomaster
networks:
trino-network-docker:
aliases:
- trinomaster
volumes:
- ../trino/master/conf/:/etc/trino/
- ../trino/data:/data/trino/
#- /.aws/:/root/.aws/
#- /.aws/:/home/trino/.aws/
ports:
- "8080:8080"
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- PROJECT_NAME=${COMPOSE_PROJECT_NAME}
- DISCOVERY_URI=${DISCOVERY_URI}
- HIVE_METASTORE_URI=${HIVE_METASTORE_URI}
- INCLUDE_COORDINATOR=${INCLUDE_COORDINATOR}
command: sh -c 'sed -i "/coordinator=/d" /etc/trino/config.properties &&
echo coordinator=true >> /etc/trino/config.properties &&
sed -i "/discovery.uri/d" /etc/trino/config.properties &&
echo discovery.uri=${DISCOVERY_URI} >> /etc/trino/config.properties &&
sed -i "/hive.metastore.uri/d" /etc/trino/catalog/hive.properties &&
echo hive.metastore.uri=${HIVE_METASTORE_URI} >> /etc/trino/catalog/hive.properties &&
sed -i "/node-scheduler.include-coordinator/d" /etc/trino/config.properties &&
echo node-scheduler.include-coordinator=${INCLUDE_COORDINATOR} >> /etc/trino/config.properties &&
sed -i "/discovery-server.enabled/d" /etc/trino/config.properties &&
echo discovery-server.enabled=true >> /etc/trino/config.properties &&
/usr/lib/trino/bin/run-trino'
healthcheck:
test: /usr/lib/trino/bin/health-check
interval: 60s
retries: 5
start_period: 30s
timeout: 30s
depends_on:
- hive-metastore
trino-worker:
build:
dockerfile: ../trino/Dockerfile
context: ../trino
image: 10.208.1.5:5000/trinodb/trino:latest
hostname: "Trino-Worker-{{.Node.Hostname}}"
networks:
- trino-network-docker
volumes:
- ../trino/worker/conf/:/etc/trino/
- ../trino/master/conf/catalog/:/etc/trino/catalog
- ../trino/data:/data/trino/
#- /.aws/:/root/.aws/
#- /.aws/:/home/trino/.aws/
ports:
- "8081-8099:8080"
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- PROJECT_NAME=${COMPOSE_PROJECT_NAME}
- DISCOVERY_URI=${DISCOVERY_URI}
- HIVE_METASTORE_URI=${HIVE_METASTORE_URI}
- INCLUDE_COORDINATOR=${INCLUDE_COORDINATOR}
command: sh -c 'sed -i "/coordinator=/d" /etc/trino/config.properties &&
echo coordinator=false >> /etc/trino/config.properties &&
sed -i "/discovery.uri/d" /etc/trino/config.properties &&
echo discovery.uri=${DISCOVERY_URI} >> /etc/trino/config.properties &&
sed -i "/hive.metastore.uri/d" /etc/trino/catalog/hive.properties &&
echo hive.metastore.uri=${HIVE_METASTORE_URI} >> /etc/trino/catalog/hive.properties &&
sed -i "/node-scheduler.include-coordinator/d" /etc/trino/config.properties &&
echo node-scheduler.include-coordinator=${INCLUDE_COORDINATOR} >> /etc/trino/config.properties &&
/usr/lib/trino/bin/run-trino'
healthcheck:
test: /usr/lib/trino/bin/health-check
interval: 60s
retries: 5
start_period: 30s
timeout: 30s
depends_on:
- hive-metastore
- trino-master
networks:
trino-network-docker:
name: trino-network-docker
driver: overlay
attachable: true