1

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!

Eddysanoli
  • 481
  • 2
  • 8
  • 17
  • Are you building a custom image for Postgres, or pulling the official image off Dockerhub? If custom, show your Dockerfile in your question. Also, any reason you want to run a database this way instead of using Amazon RDS or Aurora? – Mark B May 20 '21 at 18:35
  • I'm pulling the image from dockerhub (postgres:11). Right now I'm working on a proof of concept and the use of other services is restricted because of permissions and some financial considerations. The thing that bothers me is that it should work, its not that complicated. – Eddysanoli May 20 '21 at 18:40

0 Answers0