Secrets in configs

Hey everyone,

I have a rather specific question i couldn’t find an answer on the internet so far.

I have the following config

db.getSiblingDB("unifidb").createUser({user: "unifi", pwd: "abc123", roles: [{role: "dbOwner", db: "unifidb"}]});
db.getSiblingDB("unifidb_stat").createUser({user: "unifi", pwd: "abc123", roles: [{role: "dbOwner", db: "unifidb_stat"}]});

is there anyway I can use a secret in place of the password? This specific config is for preparing the DB for the unifi network application.

i know you can use in simple environment assignments like

MY_PASSWORD=/run/secrets/my_pw

but couldn’t get something similar working for the above.

Greetings
ThaMighty

I don’t understand the question.

You can place your two lines or the password itself in a Docker secret (doc), then load it in your code. Or use env vars and load it in your code.

I feel like an idiot not thinking about that my self.

Thanks for your answer.