I want to create an environment variable dynamically, whenever the docker-compose up happens or containers get restarted automatically.
yml file:
web-app:
build: .
container_name: abc-server
ports:
- "1337:1337"
volumes:
- "abc-server-data:/usr/src/app/Volumns"
env_file:
- ./abc.config
environment:
- HOST_MACHINE_IP_ADDRESS=echo $(hostname -I)
depends_on:
mysql:
condition: service_healthy
restart: unless-stopped
secrets:
- mysql_root_password
# - server_config
here I want to send HOST_MACHINE_IP_ADDRESS everytime either docker compose up or it automatically restarts