My Overconfidence Killed Me and My Immich Installation
Everything was good, great in fact. Everything was working, but my OCD weren't okay with how a few services were set-up, so I cleaned up my yaml, commented my docker compose and felt cushty… right up until it was time to fix Immich.
I have minor beef with Immich and basically any larger project and the way they go about their Docker Compose. Basically I feel they make the assumption that they're the only thing running.
^Disclaimer: I fully accept this is all just me being too stupid and not the Immich development team.
So first things first, let's rename database to immich-database, redis to immich-redis and most importantly, let's give it a port that's not the default postgres port that everyone wants to use. Easy right? Nope.
First Immich said it couldn't find the database, so I went in and added the IP as the DB_URL to the .env. But that didn't really help, so I went back to the Docker Compose and added the path to the references to the env.
Second issue I stumble upon, is that despite the port being available as DB_PORT Immich decided it was a suggestion and not an instruction. No worries, I edit the database URL to include the port.
Okay, I'm on the home stretch now right. I mean this was working before I decided to mess around with it in the name of scalability or whatever I thought was genius at the time… except
[Nest] 7 - 04/05/2024, 6:10:23 PM ERROR [ExceptionHandler] no PostgreSQL user name specified in startup packet
What does that even mean? Why won't you work? So I do a web search and everything is saying that docker probably isn't reading the username from the env file or the Docker Compose. I try adding single quotes and no joy, double quotes, no joy. I have no idea where I've gone wrong. I feel like my beautiful simple Docker Compose now looks like Frankenstein's Monster. Help 🙏
ENV
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
# The location where your uploaded files are stored
#UPLOAD_LOCATION=immichlibrary
# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release
# Connection secret for postgres. You should change it to a random password
DB_PASSWORD="RANDOMLIES"
DB_URL=http://192.168.0.89:8765
DB_PORT=8765
# The values below this line do not need to be changed
###################################################################################
DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
REDIS_HOSTNAME=immich_redis
I don't understand why you even change the names and ports.
If you have a seperate docker-compose.yml file for Immich, the names won't clash with other services (except if container_name is duplicated, but services like postgres and redis normally get one assigned automatically).
The ports are also limited to the container networks, so running several postgres instances still allows all of them to use the default port (except you pass them through from the host, which you normally shouldn't do in closed networks like Immich's or you run all services in network_mode: host, which is often a bad idea).
Opening ports in a postgres instance is not always needed, because you can attach yourself to the container and use the cli interface to do what you need.
Also the port you opened to change the default port is only for external services or clients. Immich-server uses the internal network for connecting to postgres, which still uses the default port. You should just use immich-database:5432 and not change anything.