Docker Swarm Cluster networking with DNS and querying for SRV-records

707 views Asked by At

So I have a very simple Docker Swarm cluster, first I init it like this:

apt-get update && apt-get upgrade
apt install docker docker-compose

docker stack deploy --prune --compose-file=docker-compose.yml testapp

And this is the docker-compose.yml file:

version: "3.7"

services:
  db:
    image: postgres:10.5-alpine
    environment:
      - POSTGRES_DB=test_app_production
      - POSTGRES_USER=test_app_user
      - POSTGRES_PASSWORD=test_app_password
    ports:
      - "5432:5432"
    deploy:
      replicas: 1
      restart_policy:
        condition: "on-failure"

  redis:
    image: redis:4.0.11-alpine
    ports:
      - "6379:6379"
    deploy:
      replicas: 1
      restart_policy:
        condition: "on-failure"

How can I query the docker DNS for SRV-records? I know that I can query the DNS and get a round-robined answer:

ping db

But how can I tell the cluster which SRV-records each service has, and how can I query them from other containers?

0

There are 0 answers