Expected Outcome
Add a host mapping to the Terraform Enterprise container to resolve the TFE hostname to the private IP address of the instance.
Prerequisites
- Terraform Enterprise Flexible Deployment Options Docker
Use Case
Migrating from a Replicated installation to Flexible Deployment Options and want to enable the equivalent of hairpin_addressing
.
Procedure
- Edit the Compose
YAML
file and add theextra_hosts
block with thehostname:IP
mapping, ex:
name: terraform-enterprise
services:
tfe:
...
...
extra_hosts:
- "tfe.example.net:162.242.195.82" - Stop/Start TerraformEnterprise using Systemd(if set up), otherwise manually with:
# Commands must be run from the folder containing the Compose YAML file
docker compose down
docker compose up -d - Verify the changes have been successfully applied(replace container name appropriately if needed):
# Inspect your tfe docker container
docker inspect terraform-enterprise -f '{{.HostConfig.ExtraHosts}}'
[tfe.example.net:162.242.195.82]
# Check hosts file inside of the container
docker exec -it terraform-enterprise bash -c 'egrep $TFE_HOSTNAME /etc/hosts'
162.242.195.82 tfe.example.net
NOTE: To enable hairpin_addressing
for Terraform runs set TFE_RUN_PIPELINE_DOCKER_EXTRA_HOSTS
as described in the link below.
Additional Information
-
Docker Driver settings - FDO Docker -
extra_hosts
applied to agent containers - Docker Compose file version 3 reference