skip to Main Content

When I connect via psql with this command docker exec -it 4e18793cb23c psql -U postgres mytestdb, I can see my database and work with it. But when I connect with dbeaver to my postgres docker container, it doesn’t show me my data. But when I want to create the same database it says that it exists. Also, doing a select on the tables, it says that the table doesn’t exist.
Few things that I checked are:

  • the directory (zorin os/ubuntu) /var/lib/postgres doesn’t exist
  • Inspect docker volume shows me this:
docker volume inspect pgdata                                                                                                                                           
    [
    {

        "CreatedAt": "2024-04-13T09:03:53+02:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/pgdata/_data",
        "Name": "pgdata",
        "Options": null,
        "Scope": "local"
    }]

I don’t have Postgres directly on my machine installed.

How do I make my databases and tables and everything appear in dbeaver?

2

Answers


  1. Chosen as BEST ANSWER

    SOLUTION: this is crazy, but checking the "show all databases" in the connection settings solved this issue.


  2. Not sure how you are launching the PostgreSQL container, but that is likely to be the key. If you are using Docker Compose then something like this:

    🗎 docker-compose.yml

    version: "3.9"
    
    services:
      postgres:
        image: postgres:latest
        container_name: postgres
        ports:
          - 5432:5432
        volumes:
          - ./create-table.sql:/docker-entrypoint-initdb.d/create-table.sql:ro
          - ./pgdata:/var/lib/postgresql/data
        environment:
          - POSTGRES_USER=postgres
          - POSTGRES_PASSWORD=password
    

    The ports will ensure that the database is accessible from outside of the Docker network.

    There are two volume mounts: (1) for an initialisation script and (2) for persisting the database between sessions.

    In screenshot below you can see the Docker Compose stack running (top terminal panel), a connection using docker exec on that container (bottom terminal panel) and a connection from DBeaver.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search