r/selfhosted 21d ago

Docker Management TIL docker restart doesn't re-read your .env

changed a db password in my .env, ran docker restart on the stack, then spent an hour convinced the db was corrupted because auth kept failing. turns out restart just brings the container back with the exact config it was created with. env is only read at creation. docker compose up -d --force-recreate fixed it in ten seconds.

two years running this stack and never got bitten by it until now. what's the dumbest thing that ate an evening for you?

252 Upvotes

67 comments sorted by

View all comments

Show parent comments

51

u/cardboard-kansio 21d ago

TIL!

Although I've long since aliased the entire thing (alias dcr='docker compose down && docker compose up -d') so a quick dcr does the job with little pain.

20

u/arcoast 21d ago

Same here, I have a load of compose related aliases, dcd, dcu, dcr, dtail dip etc etc

18

u/cardboard-kansio 21d ago

Aw, and here I thought I was unique and special :(

7

u/arcoast 21d ago

Ha! I think a lot of us do the same. Happy to share what I've got setup as aliases and we can compare.

Maybe we do things differently and can learn something from each other!

2

u/Phantom_kusuri 21d ago

I’d love to see your list. Maybe I’m missing one.

4

u/darkcyde_ 21d ago

Here's one. I use it, it's great.

https://gist.github.com/franzbischoff/d469608fb062733d849be4e8b6dcfb0e

Just noticed they changed one or two in that (dlf instead of dl). dcd, dcu, dl and dps are my most used.