The problem is that your application / project is trying to access the postgres socket file in the HOST machine (not the docker container).
To solve this problem, you must either explicitly request a tcp / ip connection when using the -p flag to configure the port for the postgres container, or share a Unix socket with HOST processing using the -v flag.
: Note: Using the -v or --volume= flag means that you are sharing some space between the HOST machine and the docker container. This means that if you have postgres installed on the host machine and it starts, you are likely to run into problems.
Below I demonstrate how to start the postgres container, which is accessible from tcp / ip and unix socket. I also call the container as postgres .
docker run -p 5432:5432 -v /var/run/postgresql:/var/run/postgresql -d --name postgres postgres
There are other solutions, but I think this is the most suitable. Finally, if the application / project that needs access is also a container, itβs better to simply link them.
Vasspilka
source share