I created a docker container for a postgres database using the next Dockerfile
:
<code># Use official PostgreSQL image from Docker Hub
FROM postgres:latest
# Set environment variables for PostgreSQL
ENV POSTGRES_USER=myuser
ENV POSTGRES_PASSWORD=mypassword
ENV POSTGRES_DB=mydatabase
# Expose the PostgreSQL port
EXPOSE 5432
</code>
<code># Use official PostgreSQL image from Docker Hub
FROM postgres:latest
# Set environment variables for PostgreSQL
ENV POSTGRES_USER=myuser
ENV POSTGRES_PASSWORD=mypassword
ENV POSTGRES_DB=mydatabase
# Expose the PostgreSQL port
EXPOSE 5432
</code>
# Use official PostgreSQL image from Docker Hub
FROM postgres:latest
# Set environment variables for PostgreSQL
ENV POSTGRES_USER=myuser
ENV POSTGRES_PASSWORD=mypassword
ENV POSTGRES_DB=mydatabase
# Expose the PostgreSQL port
EXPOSE 5432
Then in my package.json i created 2 custom commands:
<code> "build-docker-db": "docker build -t postgres-db ./",
"run-docker-db": "docker run postgres-db",
</code>
<code> "build-docker-db": "docker build -t postgres-db ./",
"run-docker-db": "docker run postgres-db",
</code>
"build-docker-db": "docker build -t postgres-db ./",
"run-docker-db": "docker run postgres-db",
Using these commands, when i check the available running container using docker ps
i get my container as active.
I tried to connect with the database using webstorm and visual studio code packages, using the next data:
<code>host: host.docker.internal (also i used localhost or 127.0.0.1)
database: mydatabase
user: myuser
password: mypassword
</code>
<code>host: host.docker.internal (also i used localhost or 127.0.0.1)
database: mydatabase
user: myuser
password: mypassword
</code>
host: host.docker.internal (also i used localhost or 127.0.0.1)
database: mydatabase
user: myuser
password: mypassword
Using the steps above i get only
<code>Cannot connect to "Connection". FATAL: password authentication failed for user "myuser"
</code>
<code>Cannot connect to "Connection". FATAL: password authentication failed for user "myuser"
</code>
Cannot connect to "Connection". FATAL: password authentication failed for user "myuser"
Question: Who faced this kind of issues and how to solve it?