How to create a docker-compose setup with PostgreSQL and pgAdmin4

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey it's random code here and today we're gonna create a Docker compose setup where you can create a postgres database in one container uh PG admin so we're going to another container which is an access on localhost and I already have a working log compose file with all of this setup which I will also leave in a gist with the link in the description I will then showcase how I can start it up and then inside PG admin we can then connect to our view container by using the IP from the projects container which is an access like a simple command but first let's go through it we have a simple dog pose with that version number we have a few Services we have our DB and our PG admin we then name our DB postgres container or PG admin jet container doesn't really matter much in this case but our posters then build from a postgres image which is like main focus image on togglehub always restarts if it fails which sets are my environment variables which allow us reflect access the database so we have approachment user.root push with password called root and we create an empty socialist database called testing and knowing a bit about postgres it has a basic Port it's going to be exposing which is Port 5432 so we're just going to expose this port outwards as well because this is where PG admin would be looking and then regarding PG admin and once again have a name it's building from apigee admin 4 image and Docker Hub restart always and we create a user on this VG admin dashboard which we're actually using shortly to login and I'm going to be exposing from Port normally it's exposing support ad on localhost Port 80 I was then going to Simply port forward this support 50 50. so in the end we're going to be able to access our PG admin dashboard on Port 5050. so I would just simply from the position of my doc close file right and no it's very important to file this name Docker Dash composter yaml yaml we can simply do Docker Dash compose up and this should then take a few first time it's probably gonna take a few minutes so I'm just gonna wait for it to finish then continue and there we go our database is now ready and our PG admin application has been initialized we are then able to go into a browser and if we then go to localhost Port 5050 we should see this basic page for our PG admin and we can then log in using our predefined email and password so I'll just simply copy like that so now with admin at admin.com and our password which is just simply boot and we should then be able to log in it might take a few seconds but we now see the PG admin dashboard and as we can see here we login as adminadin.com as an internal user but for now there are no servers connected so we accidentally connected to our database and what we need to do is we need to open a new terminal we need to do Docker container Plus to see just to ensure we have the contains running and as we can see here we do we would then simply look at our postgres container and let's just copy the ID and then do Docker inspect our container and we then need to find the IP or the IP address raw our hostless database container and I then copy the IP as you can see here the IP address inside our Digi admin we then need to add a new server using the other dashboard front page it's almost add a new server and because of example just name it postgres or psdb in this case and we then need to set a connection where for the host name we need to add IP and for our user we have defined inside of dock and post file that our user is going to be root and the password is also going to be grouped route admin whatever you want to do but our password is going to root and we need to change the user to B root as well otherwise the port is the same and means database just keep push that's fine so we just in general need to set the name and the connection as I and of course our username and password if we then save this we should be able to see a postgres.tb server and inside the server we should have a few databases we should have the postgres which is like the maintenance database and our test DB which is the database we created ourselves through our host setup and if we give it a few seconds to load and clicking on it we can see it's now loaded we could then use a query tool by clicking here and also if we just took the schemas for now it's going to be actually inside schema inside tables it's going to empty but just to ensure everything works I quickly curated a few lines of SQL which we can just quickly try to ensure it works so for example first I would create table users created we can then select all the users we can let's see down here we have our users and ID username about email on we would then insert a user into this table saved all the users and here it is and one thing to note if we just went into like the area over here and now look at our tables it won't be here yet because we actually need to click on the test TP and refresh it before we can actually now see our table so this is how we can create and connect our postgres database and MPG admin dashboard using Docker enter compose if you enjoyed this quick showcase please leave a like to subscribe and I wish you a wonderful wonderful day
Info
Channel: Random code
Views: 32,426
Rating: undefined out of 5
Keywords: random code, postgresql, docker-compose, pgadmin, docker-compose postgres pgadmin, postgres, postgres pgadmin docker-compose, postgres pgadmin, docker postgres, postgres and pgadmin, docker postgresql, intro to postgres with pgadmin, docker-compose postgres, pg-admin in docker-compose, postgresql docker, connect docker postgres to pgadmin, docker compose, docker, pgadmin course, docker context, docker context create aci, odoo docker tutorial, docker image, psql in docker-compose
Id: qECVC6t_2mU
Channel Id: undefined
Length: 6min 16sec (376 seconds)
Published: Thu Feb 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.