Currently looking into containerizing a postgres database and putting it inside of an ECS service. Initially I deployed the db using docker compose
, but then modified the task definition. The task kept crashing because of the "postgres" container (dockerhub's postgres:11). When I investigated the crash (SSH into my instance and then used docker logs container_id
), this was the reason given by the log: FATAL: role "root" does not exist
.
I investigated this error and it's pretty well known that this is caused because there isn't a "root" user inside my docker container. Many of the solutions to this problem suggest the use of this command: sudo -u postgres psql root
, however, when I try to use it, I get: FATAL: role "postgres" does not exist
. Meaning that there is not a "postgres" superuser like everyone suggests in many of these posts. I also can't list the pqsl users because I once again get the "root" error.
What intrigues me the most is that I supposedly include values for the environment variables POSTGRES_USER
, POSTGRES_DB
and POSTGRES_PASSWORD
inside the container configuration in the task definition, meaning that at minimum the postgres database should be using the "POSTGRES_USER" as a superuser. However, the environment variables appear to be ignored. They are listed when using docker inspect container_id
, but then are seemingly ignored.
I'm completely lost. I saw a github issue that blamed docker volumes for this "ignoring" behavior. However, I already pruned the volumes in my instance and this gave me no results. Perhaps I should completely scrap my instance? I don't know what to do anymore. I would gladly accept any ideas or suggestions. Thanks a lot!