Boa noite, pessoal! Voces sabem como resovler o problema abaixo? O erro ocorre quando eu tento acessar o psql do container baseado no postgres a partir do arquivo Dockerfile ?
"psql: error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? /"
Dockefile:
FROM postgres:12
ENV POSTGRES_USER=postgres \
POSTGRES_PASSWORD=123456 \
POSTGRES_DB=postgres
VOLUME /var/lib/postgresql/data
COPY ./scripts/init.sql /docker-entrypoint-initdb.d/init.sql
EXPOSE 5432
Comando para criar a imagem a partir do Dockerfile:
docker image build -t post-dock-img .
Comando para criar o container a partir da imagem criada (post-dock-image):
docker container run -it --name post-dockcont -p 4040:5432 post-dock-img /bin/bash
Erro ao tentar acessar psql, perceba que eu consigo entrar no container mas nao consigo acessar o psql:
root@5a476bede994:/# psql -U postgres -d postgres
psql: error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? //<========== ERRO AO TENTAR ACESSAR O PSQL
script:
create database email_sender;
\c email_sender
create table emails (
id serial not null,
data timestamp not null default current_timestamp,
assunto varchar(100) not null,
mensagem varchar(250) not null
);