Cannot link to a non running container: /db AS /worker-app/db

Hello guys. Good day!

I’m stuck with this problem and I can’t quite figure out why:


Course: Docker for the Absolute Beginner
Chapter: Docker Comepose - Demo - Example Voting application
Video link here: Docker for the Absolute Beginner - KodeKloud
Time stamp: 12: 40


In the demo video, the docker run order is:

  1. run redis
  2. run voting-app
  3. run postgres
  4. run worker-app

In the demo video, when Mumshad runs step 3, the postgres is up and running so the worker gets linked no problem in the 4th step. But when I run step 3 postgres, it exits immediately and I can’t link the worker in the next step.

I am aware that you can’t run a container without any process running in it. I followed exactly what Mumshad did. Not a single word changed in my attempt. What’s the magic that I’m missing here? How can you keep postgres alive?

I’d appreciate anybody’s input,
Thank you!

Run Postgres with the below command:

docker run --name=db -e POSTGRES_HOST_AUTH_METHOD=trust postgres:9.4

Hey Ayman!

This solved my trouble, thank you so much!
One more question though: as I understand, POSTGRES_HOST_AUTH_METHOD=trust is rather for testing purposes cause this is not secure. What would be the right approach to get a postgres db up and running if we were to access it by actually giving preset ID and password…?