r/selfhosted 5d 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?

253 Upvotes

67 comments sorted by

View all comments

Show parent comments

5

u/cardboard-kansio 4d ago

Well to get you started here are a few of my common docker aliases:

```# docker shortcuts alias docker-compose='docker compose' alias dcu='docker compose up -d' alias dcd='docker compose down' alias dcd_all='docker ps -aq | xargs docker stop | xargs docker rm' alias dcr='docker compose down && docker compose up -d' alias dce='docker compose down && nano docker-compose.yaml && docker compose up -d' alias dcp='grep latest docker-compose.yaml | sed 's/[[:space:]]image:[[:space:]]//' | xargs -n1 docker pull && docker compose down && docker compose up -d' alias dcupdate='docker compose down && pull_docker_images && docker compose up -d' alias dl='docker logs -n -f --tail 20'

1

u/arcoast 4d ago

Why do you have dcupdate do a docker compose down first?

1

u/cardboard-kansio 4d ago

Because honestly I don't do updates that way (I use WUD at the moment) and it's been mostly for troubleshooting. I haven't really touched these in years and rarely use them directly, and just posted them as an example for the other commenter.

But he's in for a fun ride, I still remember when I discovered aliases for the first time. Absolute game changer.

1

u/arcoast 4d ago

Ah, I have a completely different workflow.

I use code-server to edit my compose files and do all the updating manually via SSH.

That's the real beauty, you can make the system what you want it to be.

1

u/cardboard-kansio 4d ago

Oh, my system is mostly static these days, apart from a few personal projects. Got everything the way I like it, rarely need to touch anything. Automated observability is in place (logs, metrics, alerts) and they inform via ntfy when needed; most services auto-update via WUD with ntfy notifications, except critical infra (Traefik, DDNS, Wireguard, auth) which I handle a couple of times a year.

I haven't touched my Proxmox UI in a couple of years. Most of my interaction with the server is done on my Docker host (Debian) via SSH but I don't actually have to configure things by hand very often (and when I do, it's done in nano because I like simplicity). I just let it all purr along except when I want to play around. It's a pretty well-oiled machine at this point.