Set sensu-go password with env var on docker

Is there a way to set the sensu admin password via env var at launch time with the docker container, or do I have to set it with sensuctl after launch? The following does not seem to work:

---
version: "3"
services:
  sensu-backend:
    image: sensu/sensu:latest
    restart: always
    environment:
      - SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD=foo
    ports:
    - "127.0.0.1:3000:3000"
    - "127.0.0.1:8080:8080"
    - "127.0.0.1:8081:8081"
    volumes:
    - "sensu-backend-data:/var/lib/sensu/etcd"
    command: "sensu-backend start --state-dir /var/lib/sensu/sensu-backend --log-level debug"

Hey,
The backend init facility is newly introduced, and the official docker container does not yet support changing the password via envvar and works to mimic previous Sensu Go releases as it hardwires the admin user and pass to the defaults that were used for Sensu Go prior to 5.16.

You can find the script that is run inside the container at /opt/sensu/bin/sensu-entrypoint.sh
It’s just a thin wrapper to handle the new init. /user/local/bin/sensu-backend is justa symlink to this wrapper script and your command is calling it.

If you can’t wait for an official updated fix to support pulling the admin creds from envvar, you should be able to build a new container based on the official one with an updated sensu-entrypoint.sh script. Instead of hardcoding the default values, you could update the logic so that it only sets the defaults if the envvars are not already set.

1 Like