Installing PostgreSQL within a docker container -
i've been following several different tutorials official 1 whenever try install postgresql within container following message afterwards
psql: not connect server: no such file or directory server running locally , accepting connections on unix domain socket "/var/run/postgresql/.s.pgsql.5432"?
i've looked through several questions here on , throughout internet no luck.
the problem application/project trying access postgres socket file in host machine (not docker container).
to solve 1 either have explicitly ask tcp/ip connection while using -p
flag set port postgres container, or share unix socket host maching using -v
flag.
:note: using -v
or --volume=
flag means sharing space between host machine , docker container. means if have postgres installed on host machine , running run issues.
below demonstrate how run postgres container both accessible tcp/ip , unix socket. naming container postgres
.
docker run -p 5432:5432 -v /var/run/postgresql:/var/run/postgresql -d --name postgres postgres
there other solutions, find 1 suitable. if application/project needs access container, better link them.
Comments
Post a Comment