Docker-compose using host environment variable

I am trying to do the following in my docker-compose.yml

But did I hit this warning? WARNING: The HOSTNAME variable is not set. Defaulting to a blank string

environment: KAFKA_ADVERTISED_HOST_NAME: ${HOSTNAME}

The HOSTNAME environment variable is obviously set on the host.

+7
docker docker-compose
source share
2 answers

You just need to export the environment variable to the docker-compose process. Try instead:

 $ export HOSTNAME $ docker-compose up 

Source: https://forums.docker.com/t/docker-compose-not-seeing-environment-variables-on-the-host/11837/2

+6
source share

The error indicating that the variable is not set looks strange.

I use host variables as follows:

 mycontainer: image: <repo>/<image>:${SERVICE_VERSION} environment: - DB_USER=${DB_USER} - DB_PASS=${DB_PASS} 
0
source share

All Articles