I don't know how to connect PgAdmin4 to a DB container containing data on docker.

Asked 2 years ago, Updated 2 years ago, 129 views

I would like to connect PgAdmin4 to a DB container with data in Win10 and WSL2 and operate it from a browser.

Use the following containers with data, and they seem to be doing well, so you can throw a query and get a table back.

Create a PostgreSQL environment with sample data input using Docker

To launch PostgreSQL and pgAdmin4 in docker-compose

I'm referring to , but it doesn't work.

Specifically, navigate to the directory where the yaml file is located and

user@DESKTOP:~/docker/postgresql$docker-compose up-d
Starting postgresql_db_1 ... done
Starting postgresql_adm_1 ... done

So I don't know what to do after this.
Could you please let me know?

Below are the contents of the docker-compose.yaml file for your reference.

version: '2'
services:
  db:
    image —postgres
    volumes:
      - ./postgresql:/var/lib/postgresql
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER:postgres
      POSTGRES_PASSWORD:postgres
      POSTGRES_DB:postgres
  adm:
    image —dpage/pgadmin4
    volumes:
      - ./pgadmin: /var/lib/pgadmin
# - ./pgadmin: /var/lib/pgadmin/storage 
    ports:
      - "80:80"
      - "443:443"
    environment:
       PGADMIN_DEFAULT_EMAIL: admin@localhost
       PGADMIN_DEFAULT_PASSWORD: adminpass

add

When I docked in WSL and opened localhost:80 from my browser, I was waiting and there was no response.
Doing exactly the same thing from Powershell allowed PgAdmin4 to open from localhost:80.
However, I don't know which host name/address should be in PgAdmin's server settings.
(I tried 127.0.0.1:80 but it didn't seem to connect.)
What should I specify?I would appreciate it if you could tell me more about it.

re-add

When I changed the image:postgres to image:tadaken3/postgres-dvdental-database in the yaml file,

"Please enter a password to connect to the server postgres for user postgres"
That's what happens.
Entering the password postgres in the yaml file does not work.
What should I specify here?

Thank you for your cooperation.

docker postgresql docker-compose wsl

2022-09-30 17:50

1 Answers

Let's take a closer look at what you set up in the YAML file.It looks like the following:

PgAdmin account information:

PGADMIN_DEFAULT_EMAIL: admin@localhost
PGADMIN_DEFAULT_PASSWORD: adminpass

PostgreSQL account information:

POSTGRES_USER:postgres
POSTGRES_PASSWORD:postgres
POSTGRES_DB:postgres


2022-09-30 17:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.