WARN[0000] The "he" variable is not set. Defaulting to a blank string

Hi guys. I’m using docker-compose to run Home Assistant ecosystem, docker-compose.yaml provided at the end of the post.
This is my second stack with Home Assistant and additional containers. First one was run successfully for about 2 years. Few weeks ago I decided to start fresh from beginning (for some known to me reason, but it is irrelevant for this question here), and in new stack I have only 4 containers in summary. However, in both cases I had below message when executing docker-compose pull or docker-compose up -d (I’m executing mentioned commands from the directory where docker-compose.yaml file is):

WARN[0000] The "he" variable is not set. Defaulting to a blank string.

It is not a problem. all containers are working as expected, and everything is good, but I am just curious and want to learn what producing this message, since I didn’t defined any “he” variable in my docker-compose.yaml
Didn’t found answer by google-foo.

docker-compose.yaml:

version: '3'

services:

  homeassistant:
    container_name: hass
    image: homeassistant/home-assistant
    volumes:
      - ./hass:/config
      - /etc/localtime:/etc/localtime:ro
#      - ./config/media:/media
#      - /var/log/fail2ban.log:/config/fail2ban-log/fail2ban.log
    devices:
      - /dev/ttyACM0:/dev/ttyACM0
    restart: unless-stopped
    network_mode: host
    depends_on:
      - mariadb
      - mosquitto

  mariadb:
    image: linuxserver/mariadb
    container_name: mariadb
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: "${ROOT_PASSWORD}"
      MYSQL_DATABASE: ha_db
      MYSQL_USER: homeassistant
      MYSQL_PASSWORD: "${PASSWORD}"
      PUID: 0
      PGID: 0
    volumes:
      - ./mariadb:/config
    ports:
      - "3306:3306"

  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    restart: unless-stopped
    ports:
      - "1883:1883"
      - "1884:1884"
    volumes:
      - "./mosquitto/config:/mosquitto/config"
      - "./mosquitto/data:/mosquitto/data"
      - "./mosquitto/log:/mosquitto/log"
      - "./mosquitto/mosquitto-no-auth.conf:/mosquitto-no-auth.conf"
    environment:
      - TZ=Europe/Belgrade
    user: "${PUID}:${PGID}"

  esphome:
    container_name: esphome
    image: esphome/esphome
    volumes:
      - "./esphome:/config"
      - "/etc/localtime:/etc/localtime:ro"
    restart: unless-stopped
    privileged: true
    network_mode: host

  vscode:
    container_name: vscode
    restart: unless-stopped
    image: linuxserver/code-server:latest
    environment:
      PASSWORD: "${PASSWORD}"
      SUDO_PASSWORD: "${PASSWORD}"
      TZ: "Europe/Belgrade"
    ports:
      - "8443:8443"
    volumes:
      - "./vscode:/config"
      - "./hass:/config/workspace"
      - "/root/docker-compose-hass-old/config:/config/workspace/hass-old"

.env file (obfuscated, sitting in same directory as docker-compose.yaml):

ROOT_PASSWORD=******************
PASSWORD=******************
PUID=0
PGID=0

Thanks upfront!

Interesting because that was my first thought and I could get the same error message just by using a .env file like this:

test=${he}

My guess is that your password contains a dollar sign follwed by “he” and it is interpreted as a variable

PASSWORD=yourpassword$he

If you want to use dollar in the password in a .env file, you can use double dollars:

PASSWORD=yourpassword$$he

or probably the more familiar solution is using apostrophes as you would in bash:

PASSWORD='yourpassword$he'
1 Like

Hehe, you are right, one of my passwords was something like:

*******$he|*********

so it took the part from dollar sign to pipe character.
Put the password into the single quotes, topic solved, thank you very much.

(It seems that we have no “mark post as solution” as on some other forums :unamused:, or I’m not see it.)

I am also encountering this issues. It says

The POSTGRES_USER variable is not set. Defaulting to a blank string.

The same error applies to other variables set in the .environment file.

I have assigned values to my variables.
I don’t know why I am having this error when I run docker-compose up -d

I have installed the latest docker-compose on my Ubuntu machine

Could you post the content of your docker-compose.yaml and .env files?
Also, is the name of your environment file .env or .environment?

Since you used docker-compose and not docker compose, are you sure?

1 Like
services:
  postgres:
    image: postgres:16
    env_file:
      - ./backend/.env
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - mynetwork

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    env_file:
      - ./backend/.env
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.backend.rule=(Host(`backend.${DOMAIN}`)) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))"
      - "traefik.http.routers.backend.entrypoints=websecure"
      - "traefik.http.routers.backend.tls=true"
      - "traefik.http.routers.backend.tls.certresolver=myresolver"
      - "traefik.http.services.backend.loadbalancer.server.port=8000"
      - "traefik.http.routers.backend-local.rule=Host(`localhost`) && (PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`))"
      - "traefik.http.routers.backend-local.entrypoints=web"
    depends_on:
      - postgres
      - traefik
    networks:
      - mynetwork

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "5173:5173"
    env_file:
      - ./frontend/.env
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.frontend.rule=Host(`${DOMAIN}`) || Host(`www.${DOMAIN}`) && PathPrefix(`/`)"
      - "traefik.http.routers.frontend.entrypoints=websecure"
      - "traefik.http.routers.frontend.tls=true"
      - "traefik.http.routers.frontend.tls.certresolver=myresolver"
      - "traefik.http.routers.frontend.middlewares=https-redirect@docker,www-redirect@docker"
      - "traefik.http.routers.frontend-local.rule=Host(`localhost`) && PathPrefix(`/`)"
      - "traefik.http.routers.frontend-local.entrypoints=web"
      - "traefik.http.services.frontend.loadbalancer.server.port=5173"
      - "traefik.http.middlewares.api-proxy.forwardauth.address=http://frontend:5173/api-proxy"
      - "traefik.http.routers.frontend-http.rule=Host(`${DOMAIN}`) || Host(`www.${DOMAIN}`) && PathPrefix(`/`)"
      - "traefik.http.routers.frontend-http.entrypoints=web"
      - "traefik.http.routers.frontend-http.middlewares=https-redirect@docker"
    depends_on:
      - backend
      - traefik
    networks:
      - mynetwork

  adminer:
    image: adminer:latest
    container_name: DB-manager
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.adminer-domain.rule=Host(`db.${DOMAIN}`) && PathPrefix(`/adminer`)"
      - "traefik.http.routers.adminer-domain.entrypoints=websecure"
      - "traefik.http.routers.adminer-domain.tls=true"
      - "traefik.http.routers.adminer-domain.tls.certresolver=myresolver"
      - "traefik.http.routers.adminer-domain-http.rule=Host(`db.${DOMAIN}`) && PathPrefix(`/adminer`)"
      - "traefik.http.routers.adminer-domain-http.entrypoints=web"
      - "traefik.http.routers.adminer-domain-http.middlewares=https-redirect@docker"
      - "traefik.http.routers.adminer-local.rule=Host(`db.localhost`) && PathPrefix(`/adminer`)"
      - "traefik.http.routers.adminer-local.entrypoints=web"
      - "traefik.http.services.adminer.loadbalancer.server.port=8080"
    ports:
      - "8080:8080"
    depends_on:
      - postgres
    networks:
      - mynetwork

  traefik:
    image: traefik:v3.1
    container_name: proxy-manager
    restart: always
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--entrypoints.traefik.address=:8090"
      - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
      - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.myresolver.acme.email=${ACME_EMAIL}"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "8090:8090"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./letsencrypt:/letsencrypt
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik-domain.rule=Host(`traefik.${DOMAIN}`)"
      - "traefik.http.routers.traefik-domain.service=api@internal"
      - "traefik.http.routers.traefik-domain.entrypoints=web"
      - "traefik.http.routers.traefik-domain-secure.rule=Host(`traefik.${DOMAIN}`)"
      - "traefik.http.routers.traefik-domain-secure.entrypoints=websecure"
      - "traefik.http.routers.traefik-domain-secure.tls=true"
      - "traefik.http.routers.traefik-domain-secure.tls.certresolver=myresolver"
      - "traefik.http.routers.traefik-domain-secure.service=api@internal"
      - "traefik.http.routers.traefik-dashboard.rule=Host(`traefik.${DOMAIN}`) && PathPrefix(`/dashboard`)"
      - "traefik.http.routers.traefik-dashboard.entrypoints=web"
      - "traefik.http.routers.traefik-dashboard.service=api@internal"
      - "traefik.http.routers.traefik-local.rule=Host(`proxy.localhost`)"
      - "traefik.http.routers.traefik-local.service=api@internal"
      - "traefik.http.routers.traefik-local.entrypoints=web"
      - "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
      - "traefik.http.middlewares.www-redirect.redirectregex.regex=^https://www\\.(.+)"
      - "traefik.http.middlewares.www-redirect.redirectregex.replacement=https://$${1}"
      - "traefik.http.middlewares.www-redirect.redirectregex.permanent=true"
    networks:
      - mynetwork

volumes:
  postgres_data:
  letsencrypt:

networks:
  mynetwork:

my .env file

DOMAIN=hng@tech
ACME_EMAIL=sapphire@gmail.com
# Postgres
POSTGRES_USER=user
POSTGRES_PASSWORD=app
POSTGRES_DB=apidb
POSTGRES_SERVER=localhost
POSTGRES_PORT=543

Which is where?

This is for example for the containers not for using the defined variables in the compose file.

1 Like

Please I don’t understand. my .env file . I was only trying to show you the variable I declared in the .env file, so I personalized it by saying my. I also tried using this method below while the .env file was in the same directory as the compose.yml. It produce the same error

environment:
    -  POSTGRES_USER=$POSTRES_USER

“where” is still a question. Please, show your folder structure or at least the relevant part that shows where your env file is and how exactly it is called. Showing us what you saved in the file doesn’t help if we don’t know you are using the correct file. And make sure you show exactly what you used, otherwise we will spend time on telling you a dozen reasons why the variables are empty when you just had a typo when you shared the values as I assume in this:

Where you obviously use $POSTRES_USERand notPOSTGRES_USER`.