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"
    image: sensu/sensu:latest
    restart: always
    - ""
    - ""
    - ""
    - "sensu-backend-data:/var/lib/sensu/etcd"
    command: "sensu-backend start --state-dir /var/lib/sensu/sensu-backend --log-level debug"

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/
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 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