Reputation: 877
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:
/var/lib/postgres
doesn't existdocker 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?
Upvotes: 1
Views: 1205
Reputation: 6564
Not sure how you are launching the PostgreSQL container, but that is likely to be the key.
Docker Client
If you are launching PostgreSQL using the Docker client then you'd do something like this:
docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=password \
--name postgres postgres:latest
You mention that you are starting your container with docker start
but I presume that this means that at some stage you would have kicked it off with docker run
.
IMHO the Docker Compose route to launching the database is better because it documents all the details associated with launching the container.
Docker Compose
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.
Upvotes: 0
Reputation: 877
SOLUTION: this is crazy, but checking the "show all databases" in the connection settings solved this issue.
Upvotes: 3