MySQL 8.0.22 の新機能で DNS SRV レコードのサポートというのがあったので試してみた。 https://dev.mysql.com/doc/refman/8.0/en/connecting-using-dns-srv.html
MySQLサーバー3台 (a.example.com, b.example.com, c.example.com)とそれに接続するためのクライアントの計4台を docker-compose で作成する。
Dockerfile
FROM ubuntu RUN apt update RUN apt install -y mysql-client libmysqlclient-dev gcc unbound bind9-dnsutils RUN rm -f /etc/unbound/unbound.conf.d/root-auto-trust-anchor-file.conf COPY entrypoint.sh / RUN chmod +x /entrypoint.sh ENTRYPOINT /entrypoint.sh
docker-compose.yml
services:
client:
build: .
hostname: client
volumes:
- ./resolv.conf:/etc/resolv.conf
- ./unbound-example.conf:/etc/unbound/unbound.conf.d/example.conf
- .:/work …[さらに読む]