I have a docker compose file with .env file, for example the .env file has this HOSTNAME=a1.test.com, and a docker-compose file has this:
... extra_hosts: - "${HOSTNAME}:1.1.1.1" - "test.com:1.1.1.1" When I run the container the /etc/hosts file content is:
1.1.1.1 1.1.1.1 test.com So the docker compose not putting the variable data during the run process.
I tried this hostname: "${HOSTNAME}" and it is working fine the host name of the container is correct a1.test.com.
Any idea how can achieve what I want?