It should look like this: listen_addresses = 'localhost,192.168.0.11'. To do that, sudo nano /etc/postgresql/12/main/nf and then find and uncomment the config for listen_addresses amd add your YOUR_LOCAL_IPV4_ADDRESS from earlier.
![pgadmin 4 docker pgadmin 4 docker](https://res.cloudinary.com/practicaldev/image/fetch/s--FNvTD0z1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/phdp5tcq1133yrroub35.jpg)
If you still can’t connect to the Postgres server, you may need to let Postgres know that it can accept connections from address other than ‘localhost’. Now if you try to add the server in pgAdmin, it should succeed. Restart postgres sudo service postgres restart. You will need to edit the configuration file to add the docker IP address as trusted: sudo nano /etc/postgresql/12/main/pg_hba.conf and add this line host all all 172.17.0.2/24 trust to the ‘# IPv4 local connections:’ block.
![pgadmin 4 docker pgadmin 4 docker](https://linuxhint.com/wp-content/uploads/2020/03/40-1.png)
To do that, you can run the following commands: sudo -u postgres psql Copy that IP, in my case it was 172.17.0.2. That is the IP of your running pgAdmin docker container. If you try to add the new server, you will most likely get an error notice about Postgres complaining about an IP not having access.
#Pgadmin 4 docker how to#
The password is something you should know, otherwise see this comment on StackOverflow how to reset your postgres password. Once ui interface is started, it will have a container running as shown. For the hostname use database since we defined that earlier in the command above. docker run -p 8080:80 -e -e PGADMINDEFAULTPASSWORDpgAdmin -d -nameui-pgadmin dpage/pgadmin4 here pgAdmin container exposes on port 8080. Next, from the ‘Quick Links’ section on the pgAdmin dashboard, you can add a new server. If everything went well until this point, you should be able to access pgAdmin4 at and log in with the email and password you specified in the command above. You may need to restart your terminal so that the alias is loaded.
![pgadmin 4 docker pgadmin 4 docker](https://i.ytimg.com/vi/5QNL7_i-ay8/hqdefault.jpg)
Next, start pgAdmin by running pgadmin-boot or the command above. The YOUR_LOCAL_IPV4_ADDRESS is the IP address of your computer on the local area network, assuming Postgres is running from your local machine. Next, I added the following command to my ~/.bash_aliases so I can quickly run the container:Īlias pgadmin-boot='docker run -add-host=database:YOUR_LOCAL_IPV4_ADDRESS -p 5050:80 -e "PGADMIN_DEFAULT_EMAIL=YOUR_PGADMIN_LOGIN_EMAIL" -e "PGADMIN_DEFAULT_PASSWORD=YOUR_PGADMIN_LOGIN_PASS" -d dpage/pgadmin4' This assumes you already have Docker installed in your Ubuntu.įirst, docker pull dpage/pgadmin4 to pull the image on your computer. Congratulations, you are successfully running a PostgreSQL database and pgadmin4 on your machine using Docker. The command docker compose up starts and runs the entire app. Until this is solved, or in case you want to run pgAdmin from a Docker container, here’s what worked for me. Now run the following command from the same directory where the docker-compose.yml file is located. ApDockerized pgAdmin 4 & local Postgres server on Ubuntu 20.04Īt this time of writing, pgAdmin4 is not available for installation on Ubuntu 20.04, due to an unresolved Python dependency.