I'm trying to do the following in my docker-compose.yml
But 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.
In Docker Compose, IT admins can use environment variables to generalize configurations for different situations, deployment environments and security contexts without editing the main project file(s) manually. Variables can either be passed as command-line arguments -- suitable for only a few parameters -- or via a .
You can pass the values of environment variables from the host to your containers without much effort. Simply don't specify a value in the command line, and make sure that the environment variable is named the same as the variable the containerized app expects: $ docker run -e var_name (...)
Use -e or --env value to set environment variables (default []). If you want to use multiple environments from the command line then before every environment variable use the -e flag. Note: Make sure put the container name after the environment variable, not before that.
An error saying the variable is not set looks strange indeed.
I use host variables like this:
mycontainer:
image: <repo>/<image>:${SERVICE_VERSION}
environment:
- DB_USER=${DB_USER}
- DB_PASS=${DB_PASS}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With