Pgadmin does not start with docker-compose-file - postgresql

I started working with postgres and discovered pgadmin.
I started like this:
Postgres:
$ docker run --name admin -e POSTGRES_PASSWORD=admin -p 5432:5432 -d postgres:latest
Pgadmin:
docker run -p 5050:80 -e "PGADMIN_DEFAULT_EMAIL=admin#admin.com" -e "PGADMIN_DEFAULT_PASSWORD=root" -d dpage/pgadmin4
So this worked perfectly fine, I started the postgres container and afterwarda the pgadmin cointainer and got on the site http://localhost:80/login and could login
The problem now is the docker-compose.yml that I wrote. As I deploy my docker-compose-file, the containers are both running but I can't access the login page of pgadmin
Docker-compose.yml:
version: '3.8'
services:
db:
image: postgres:latest
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
ports:
- "5432:5432"
pgadmin:
image: dpage/pgadmin4:latest
environment:
PGADMIN_DEFAULT_EMAIL: admin#admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"

When I run it, it works as it should. So I think your issue is the URL you try to access it on. You need to access it on the mapped port 5050. Not 80, as you've written. So the URL is http://localhost:5050/login.

Related

can't access Postgres db on Mac when I set port: 5432:5432 but it works fine when I set to 5001:5432

I was setting up docker compose
version: "3.7"
services:
postgres:
container_name: mydevdb
image: postgres:13
restart: always
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
postgres:
my env file
POSTGRES_USER=username
POSTGRES_PASSWORD=password
POSTGRES_DB=dev
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}#localhost:5432/${POSTGRES_DB}?schema=public
and when I run Prisma Migrate dev it logs:
Error: P1010
User `username` was denied access on the database `dev.public`
but when I changed ports in docker-compose.yml to "5001:5432"
and updated my DATABASE_URL port from 5432 to 5001 it works fine .. I just don't know why that happens in my Mac however my ubuntu machines works well with 5432:5432 port
You probably have another instance of postgres running on your mac.
You can run
sudo lsof -PiTCP -sTCP:LISTEN | grep 5432
to check.

Docker Postgres and Adminer accept connection but doesn't work

On my rasperry pi 4 I've installed docker and docker-compose and now I'm tring to install and use Postgres and Adminer
following that https://hub.docker.com/_/postgres I've created docker-compose.yaml file as follow:
# Use postgres/example user/password credentials
version: '3.1'
services:
db:
image: postgres
restart: unless-stopped
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
adminer:
image: adminer
restart: unless-stopped
ports:
- 8080:8080
and i run it with
docker-compose -f docker-compose.yaml up -d
after that DB_1 starts and adminer too
but when i try connect to http://192.168.1.38:8080/ i can't reach it
even if i try connect to postgres through pgAdmin it's says
could not connect to server: Connection refused (0x0000274D/10061) Is
the server running on host "192.168.1.38" and accepting TCP/IP
connections on port 5432?
however if i don't use docker-compose but just
docker run --name postgres -d --restart unless-stopped -p 5432:5432 -e POSTGRES_PASSWORD=123456 -v ${PWD}/data:/var/lib/postgresql/data postgres
it's work through pgAdmin
do you know what i'm doing wrong?
UPDATE: seems the problem is with docker-compose because any kind of docker-compose.yml file block connection to it...
with a container with djgango i tried to start server and it's works but when i try reach page it seem bloccked too
when i run docker-compose.yaml file docker-compose ps output is:
sudo netstat -tulpn screenshot
PgAdmin can't reach 5432 ports because you don't expose it.
Like for Adminer you need to expose the Postgres port 5432 on your machine in your compose file.
version: '3.1'
services:
db:
image: postgres
restart: unless-stopped
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
adminer:
image: adminer
restart: unless-stopped
ports:
- 8080:8080
a little late to the party but what you need to do is figure out the IP address of the postgres container, and use that as your host.

Spring boot docker container is running, but cannot access via localhost/browser

I have tried to search other questions, but the solutions arent cutting it.
I have a java spring boot application running inside docker, using the command below:
docker run -p 8080:80 -v C:/Users/USER/Desktop/brapi:/home/brapi/properties --network=brapi_network -d brapicoordinatorselby/brapi-java-server:v2
Container is running. However, when I click 'open in browser', browser says:
This page isn’t working
localhost didn’t send any data. (ERR_EMPTY_RESPONSE)
What am I missing here? I tried to find my yaml file but I couldnt (beginner here)
Any help would be much appreciated
Spring boot default port is 8080.
My best guess is you're trying to map docker port 8080 to your port 80. In that case, flip your port syntax.
If you have any arguments, then don't forget to provide them in syntax:
docker run \
-p 80:8080 \
-e JAVA_OPTS="-Dspring.profiles.active=dev" \
-v C:/Users/USER/Desktop/brapi:/home/brapi/properties \
--network=brapi_network \
-d brapicoordinatorselby/brapi-java-server:v2
I faced the same issue
you need to have pgadmin(graphical user interface client)in your docker-compose.yml file
In my case I wrote my docker-compose.yml like this and it works properly
services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: amigoscode
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4#pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgres:
pgadmin:

cannot access postgres running in docker via pg_isready or pgAdmin

I have a simple postgres running in docker. Everything works ok. I also can access it via:
docker exec -it db bash and there using psql.
But both pg_isready and pgAdmin fail to access it via localhost at port 5432
version: "3"
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- db-data:/var/lib/postgresql/data
networks:
frontend:
aliases:
- db
That's how the container status look like:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9295d519be2s postgres "docker-entrypoint.s…" 15 minutes ago Up 15 minutes 0.0.0.0:5432->5432/tcp ebot_db_1
What is wrong?

Connecting docker postgres to pgAdmin

Given this docker-compose.yml, am experiencing difficulties connecting the docker stack to my pgAdmin.
version: '3.1'
services:
database:
image: postgres
restart: always
environment:
POSTGRES_USER: db-user
POSTGRES_PASSWORD: db-user
POSTGRES_DB: db
ports:
- 5432:5432
For the pgAdmin Connection properties, here's what I've used (others, default values):
Host: 127.0.0.1
Username & Password: db-user
And for the error message when saving:
Error saving properties: UNAUTHORIZED
Unable to connect to server
The docker postgresql page suggest the stack.yml:
# Use postgres/example user/password credentials
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
And then visit http://localhost:8080.
Or:
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" ...
In your case, adding port to the database itself suggests your queries should use that port.