Files
computer-playbook/roles/docker-container/templates/networks.yml.j2
Kevin Veen-Birkenbach d4c62dbf72 docker-container: ensure explicit network alias for DB services
Added explicit aliases in the networks configuration for database containers
(Postgres/MariaDB). This guarantees that the configured 'database_host' is always
resolvable across external networks, fixing intermittent 'UnknownHostException'
issues when restarting dependent services (e.g., Confluence).

Ref: https://chatgpt.com/share/68cabfac-8618-800f-bcf4-609fdff432ed
2025-09-17 16:26:02 +02:00

17 lines
740 B
Django/Jinja

{# This template needs to be included in docker-compose.yml containers #}
networks:
{% if
(applications | get_app_conf(application_id, 'features.central_database', False) and database_type is defined) or
application_id in ['svc-db-mariadb','svc-db-postgres']
%}
{{ applications | get_app_conf('svc-db-' ~ database_type, 'docker.network') }}:
aliases:
- {{ database_host }}
{% endif %}
{% if applications | get_app_conf(application_id, 'features.ldap', False) and applications | get_app_conf('svc-db-openldap', 'network.docker') %}
{{ applications | get_app_conf('svc-db-openldap', 'docker.network') }}:
{% endif %}
{% if application_id != 'svc-db-openldap' %}
default:
{% endif %}
{{ "\n" }}