I try to up postgresql and adminer via docker container. But from adminer I cannot enter to postgresql with password and user I whote.
SQLSTATE[08006] [7] FATAL: password authentication failed for user "root"
I tried all.
version: '3'
services:
web:
build: .
environment:
- APACHE_RUN_USER=www-data
volumes:
- ./blog:/var/www/html/
ports:
- 8080:80
working_dir: /var/www/html/
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: kisphp
POSTGRES_USER: root
POSTGRES_DB: kisphp
ports:
- "5432:5432"
volumes:
- ./postgres:/var/lib/postgresql/data
adminer:
image: adminer
restart: always
ports:
- "6080:8080"
This docker-compose configuration works well.
Try recreating it from scratch:
Delete ./postgres folder
docker-compose stop
docker-compose down
docker-compose up -d
Related
I have setup from a tutorial a pgadmin4 container and a PostgreSQL container with the following docker-compose:
version: "2"
services:
db:
image: postgres:14
restart: always
environment:
POSTGRES_DB: postgres
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
PGDATA: /var/lib/postgresql/data
volumes:
- db-data:/opt/docker/pgadmin4/postgresql/data
- /home/laurent/Documents/Informatique/Docker/sample-database:/opt
ports:
- "5432:5432"
pgadmin:
image: dpage/pgadmin4:4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin#linuxhint.com
PGADMIN_DEFAULT_PASSWORD: secret
PGADMIN_LISTEN_PORT: 80
ports:
- "8080:80"
volumes:
- pgadmin-data:/var/lib/pgadmin
- /home/laurent/Documents/Informatique/Docker/sample-database:/opt
links:
- "db:pgsql-server"
volumes:
db-data:
pgadmin-data:
In both conainers, I have mounted the path /home/laurent/Documents/Informatique/Docker/sample-database where I have put a sample database.
After having created the dvdrental database as explained in the tutorial, I try to import it with restore, but I cannot find my /opt/dvdrental.tar as expected.
When I Select file, I get this:
If I add opt in the path and refresh, nothing more.
But if I open a console in both containers, I have /opt/dvdrental.tar.
What do I miss?
I'm running pgAdmin using docker-compose with the following script:
version: "3.9"
services:
postgres:
image: "postgres:13"
container_name: "postgres"
environment:
POSTGRES_PASSWORD: pwd
ports:
- "5432:5432"
volumes:
- ./initdb:/docker-entrypoint-initdb.d
pgadmin:
image: "dpage/pgadmin4"
container_name: "pgadmin"
environment:
PGADMIN_DEFAULT_EMAIL: pgadmin#mycomp.com
PGADMIN_DEFAULT_PASSWORD: secret
links:
- postgres:postgres
ports:
- 5050:80
The script uses PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD to change the default pgAdmin credentials.
However, as I'm running this docker instance on a development machine, I would like to auto-login into pgAdmin.
Is it possible to disable the login / automatically login?
You have to set SERVER_MODE parameter to False on your development machine. Due to documentation you should use PGADMIN_CONFIG_SERVER_MODE in your docker-compose.yml:
version: "3.9"
services:
postgres:
image: "postgres:13"
container_name: "postgres"
environment:
POSTGRES_PASSWORD: pwd
ports:
- "5432:5432"
volumes:
- ./initdb:/docker-entrypoint-initdb.d
pgadmin:
image: "dpage/pgadmin4"
container_name: "pgadmin"
environment:
PGADMIN_DEFAULT_EMAIL: pgadmin#mycomp.com
PGADMIN_DEFAULT_PASSWORD: secret
PGADMIN_CONFIG_SERVER_MODE: 'False'
links:
- postgres:postgres
ports:
- 5050:80
Now if you have a problem with the missing crypt key, you can disable MASTER_PASSWORD by specifying this parameter:
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: 'False'
Experimenting with Postgres and Pgadmin4 with Docker Compose. Initially I use this as my docker-compose.yml file.
version: '3.8'
services:
db:
container_name: pg_container
image: postgres
restart: always
volumes:
- ./postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: test_db
ports:
- "5432:5432"
pgadmin:
container_name: pgadmin4_container
image: dpage/pgadmin4
restart: always
volumes:
- ./data/pgadmin:/var/lib/pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: admin#admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
links:
- "db:psql-server"
I ran:
chown -R 5050:5050 data
So that pgadmin4 could save it's configuration and it worked beautifully. Then I tried to bring it down and update the POSTGRES_PASSWORD to test.
docker-compose down
UPDATED docker-compose.yml file to:
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: test
And then brought it back up:
docker-compose up
To my surprise when connecting to Postgres from Pgadmin4 test does not work as the password, but root does. So my question is when Postgres creates the data directory does it store the credentials somewhere in there? Is there a way to update the password and user once it has been initially created?
I'm trying to run pgadmin and postgres on docker. both services seems to work. However to able to connect to postgres through pgadmin. return password incorrect even after typing the password you see in the docker-compose file.
docker-compose
services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: danny329
POSTGRES_PASSWORD: danny329
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin_container
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:
Error screenshot:
Note: the password i used is 'danny329'
Since both your postgres container and pgadmin container are running on the same Docker bridge network, you can connect them to each other using thier container name. For more info see Networking in Compose
In this case for the pgadmin you can set the hostname to be postgres:
I have the following docker-compose:
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: postgres
volumes:
- postgres:/pgdata
ports:
- "5432:5432"
pdadmin:
image: dpage/pgadmin4
restart: always
ports:
- "8080:80"
environment:
PGADMIN_DEFAULT_EMAIL: example#gmail.com
PGADMIN_DEFAULT_PASSWORD: example
volumes:
postgres:
when I try to login to postgres via pgadmin i am getting the error: password authentication failed for user "postgres"
I am trying with user postgres and password postgres.
I also tryied to add explisit POSTGRES_USER to the env with no success.
How can I login to my postgres database?
Thanks
you're very close:
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_USER: postgres # <-- add this
POSTGRES_PASSWORD: postgres
volumes:
- postgres:/pgdata
ports:
- "5432:5432"
pdadmin:
image: dpage/pgadmin4
restart: always
ports:
- "8080:80"
environment:
PGADMIN_DEFAULT_EMAIL: example#gmail.com
PGADMIN_DEFAULT_PASSWORD: example
depends_on: # <-- add this
- db # <-- add this
links: # <-- add this
- db # <-- add this
volumes:
postgres:
Then connect to pgadmin http://localhost:8080
when you want to add new server you need to add the IP of the container
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_id>
That it !
try it
PGADMIN_DEFAULT_PASSWORD: Example123
Use a mixture of upper and lower case letters and numerics