Installed Postgresql and Zeppelin in containers. Cant access PG from Zeppelin via jdbc

Installed Postgresql and Zeppelin in containers. Cant access PG from Zeppelin via jdbc. When I connect PG from dbeaver works ok.

My actions:

# net setting
docker network create pg_net

# install PG
docker run --name pg -e POSTGRES_PASSWORD=pg_admin -p 5432:5432 -v pg_vol:/var/lib/postgresql/data --net pg_net -d postgres

# zeppelin settings
docker run -p 8080:8080 --net pg_net -v $PWD/notebook:/notebook -e ZEPPELIN_NOTEBOOK_DIR='/notebook' --name zeppelin apache/zeppelin:0.12.0

# JDBC PG interpreter in Zeppelin settings (jdbc)
default.url: jdbc:postgresql://localhost:5432/
default.user: postgres
default.password: pg_admin
default.driver: org.postgresql.Driver

run in Zeppelin:

%jdbc

select 1;

Please help!

This can’t be correct. The host and each container use different network namespaces, thus for everyone localhost is different.

Since you already use a user defined network, you can use dns-based service discovery. Within the same network (except in the default bridge) you can reach other containers using the container name.

Since you postgress container uses --name pg you need to use:

default.url: jdbc:postgresql://pg:5432/

Thanks a lot! It helped!