Spin up a Postgres Instance & PGADMIN with Docker
Key Takeaways
The video demonstrates how to spin up a Postgres instance and PGADMIN with Docker, using commands such as docker run and environment variables to configure the containers.
Full Transcript
you're gonna open your the terminal window and zoom in a little bit here so you can see and then that terminal window I'm gonna write docker run and then I want to write phosphorous so these are the three words that you need in order to spin up Postgres in stow container that will download them as you'll need an internet connection to download them is for the first time I have the image already done right so it's gonna be faster than you're probably right so you can do that and it will run but before I want to do that I want actually since Postgres is a database right if you want to listen to a port right bhaskar's listen by default in port 4 5 4 3 2 right and in order to listen to that port you need to actually expose that poor to your host ok and in order to do that you will use the /b 4 port ok and then I'm gonna expose the same exact port 5 4 3 2 that's my host port and that's the container port right this is like kind of a mapping so this means that hey when you when you spin up a docker container it will spin up on this port right five four three two all the time right but what pour do you want to map it in the the host which is my machine which is my Mac in this case right and for font I am going to give this container a name you don't have to is gonna assign it a random name like sleazy Joe whatever right but I'm gonna give it and really name I'm just like called PG okay and that's hit enter let's see what happens mmm and database is ready and to accept connections how simple and cool is that guys right this is really cool right in your case it might take slightly more time the reason is problems it's gonna download image do all that stuff obviously we don't have a way to test that database right unless we write some code but to do that I'm gonna spin up another docker container that have PG admin and if you're familiar with Postgres PG admin is actually the administrator interface that administer if you will the Postgres databases and it's a whoop server essentially so again lessons to a port and to do that it's gonna be like a mini web server listening to a port will have a web application that manages nicely lit manages your Postgres database so let's go ahead and spin up a door a post Chris no PG admin ok PG admin is managed by the David page right that's the official that's the that's the official report that I found actually and to do that again docker run only if I can spell doctor right and since obviously we're gonna spin it in on port PJ I mean this is the knowledge right you have to know PG admin runs on port 80 that particular image that we're gonna run apart runs on first 80 so I can map it to port 80 right but I don't want to do that because port it is already in use here I'm using it for nginx so I'm gonna just literally any other port right I'm gonna use five five five five yeah and after we do that another requirement here is let's write the name of the container PG admin again this this part is completely optional but it's cool to have like so you can do docker start PG admin docker stop pretty admin like yeah that's it's cool to have a name for your container otherwise you get a sleazy Jo sleazy Arthur whatever okay the name of the image is deep age PG item four okay that is almost we're almost there okay so we have dr. Ron right we have the poor roots five five five mapping to port 80 we have the name and we have the D page /pg Edmond for what we need to do is actually the requirement is since it's a webserver since it's a it's actually an application so there is a credential default credential there are obviously you have to put this default credential as an environment variable and to do that you're gonna use /e not / - e as an environment variable when the environment variable in this case is literally PG admin underscore default underscore we are our line underscore email okay and although says email you don't have to have an email just like I'm gonna name it Hossein that works right it's it's no really it doesn't have to be an email per se and then I'm gonna add another environment variable - you have to do that and then PG admin underscore default underscore password okay hopefully easy to remember my password is so secure it's called [Applause] okay and I think that is all we need and then just like that we are running on port five five five five mapping to port 80 and let's okay so now I have Postgres running and I have PG admin running so how to disappear since it's our web application your browser is your friend right unfortunately you cannot hit the the Postgres database directly from the browser right because it's TCP so I'm gonna do Hussein Mac that's my machine name and then guess what was five five five five and just like that we're gonna be prompted with the email and password which was the environment variable where we provided which was retracted just Hussein and the infamous password and then login we have a blank slate of nothingness right we have the beautiful beach Edmond we don't have any servers so how can we connect to our if only we have a database that we can't connect to oh we actually do sir we do where is it listening it's listening on port five four three two I can change that by the way right we're gonna show you in a minute that's the beauty of this we're gonna spin up another database on our report but let's add the first one first I'm gonna name this my DB one okay let's go yeah my my PG DP docker whatever you can't call whatever you want this is just a name the host the host is Jose Mac that's the machine name right and the port is happen to be the same five four three two remember we mapped five four three two two five five four three two and the default password is Postgres and Postgres okay and then you go ahead and you connected and then you can do all sorts of cool things by default posting export squares you can start creating it database right do you be I just created database why not you can create tables and all sort of cool things that's great another instance guys before we end this video so I'm gonna do doc Iran uh - P 543 one really mapping - five four three two which is the port that is the database port right that Postgres database board and I am going to name it PG to the instance - and I Postgres I think that said I think that's it that will spin up another database how simple is that guys if you if you if you do not use your containers you have to install it twice there is no way you can install well I'm lying you can actually install two Postgres in the same machine we have to configure for them different port but it's it's really really tedious right but this you can just stop a container start on another containers you're so simple right so I'm gonna create another server docker - what's the host name same host name but the port is five four three one can i connect sir can i connect oh we are connected right it's a blank slate there is not a single day there's once database right and the other one has two database [Music]
Original Description
Commands
#POSTGRES
docker run -p 5432:5432 --name pg postgres
#PGADMIN
docker run -e PGADMIN_DEFAULT_EMAIL="hussein” -e PGADMIN_DEFAULT_PASSWORD=“password” -p 5555:80 --name pgadmin dpage/pgadmin4
🏭 Software Architecture Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQXNP6mQchJVP3S-3oKGEuw9
💾 Database Engineering Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQXjD0HOzN7P2tgzu7scWpl2
🛰 Network Engineering Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQUBSgBXilKhRMJ1ACqr7pTr
🏰 Load Balancing and Proxies Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQVMeBmWI2AhxULWEeo7AaMC
🐘 Postgres Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQWGrOqslniFlRcwxyY94cjj
🚢Docker
https://www.youtube.com/playlist?list=PLQnljOFTspQWsD-rakNw1C20c1JI8UR1r
🧮 Programming Pattern Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQV1emqxKbcP5esAf4zpqWpe
🛡 Web Security Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQU3YDMRSMvzflh_qXoz9zfv
🦠 HTTP Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQU6zO0drAYHFtkkyfNJw1IO
🐍 Python Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQU_M83ARz8mDdr4LThzkBKX
🔆 Javascript Videos
https://www.youtube.com/playlist?list=PLQnljOFTspQWab0g3W6ZaDM6_Buh20EWM
👾Discord Server https://discord.gg/CsFbFce
Support me on PayPal
https://bit.ly/33ENps4
Become a Patreon
https://www.patreon.com/join/hnasr?
Stay Awesome,
Hussein
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Hussein Nasser · Hussein Nasser · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Extending ArcObjects (IGeometry) - 01 - Getting Started
Hussein Nasser
Extending ArcObjects (IGeometry) - 02 - The Document, The Map and The Layers
Hussein Nasser
Channel Update - New Book, New Job, New Videos
Hussein Nasser
Learn Programming with VB.NET - 01 - Getting Started
Hussein Nasser
Learn Programming with VB.NET - 02 - Classes and Objects (Part 1)
Hussein Nasser
Learn Programming with VB.NET - 03 - Classes and Objects (Part 2)
Hussein Nasser
Learn Programming with VB.NET - 04 - User Interface
Hussein Nasser
Learn Programming with VB.NET - 05 - By Value v. By Reference
Hussein Nasser
Learn Programming with VB.NET - 06 - Variable size, 32 bit vs 64 bit
Hussein Nasser
Learn Programming with VB.NET - 07 - Conditional Statements
Hussein Nasser
Learn Programming with VB.NET - 08 - Inheritance
Hussein Nasser
Learn Programming with VB.NET - 09 - Strategy Design Pattern
Hussein Nasser
Learn Programming with VB.NET - 10 - How did I learn programming
Hussein Nasser
IGeometry 2016 Retrospective - Channel Update
Hussein Nasser
Javascript by Example - The Vook
Hussein Nasser
Vlog - Keep your servers close and your database closer
Hussein Nasser
Vlog - Client/Server Programming Languages
Hussein Nasser
Javascript By Example L1E01 - Getting Started
Hussein Nasser
Persistent Connections (Pros and Cons)
Hussein Nasser
Javascript By Example L1E02 - Building the Calculator Interface
Hussein Nasser
Happy new Year from IGeometry!
Hussein Nasser
Synchronous v. Asynchronous
Hussein Nasser
Javascript By Example L1E03 - Displaying the Digits on Calculator Screen
Hussein Nasser
Show Your Work. Blog, Vlog, Write, Create and Develop!
Hussein Nasser
Relational Database Atomicity Explained By Example
Hussein Nasser
Javascript By Example L1E04 - Operators, All Clear with Arrow Functions
Hussein Nasser
What Comes First, User Experience or Software Architecture?
Hussein Nasser
Javascript By Example L1E05 - Evaluate the Calculator Expressions with eval
Hussein Nasser
Fastest Way to Learn Programming Language or Technology
Hussein Nasser
Javascript By Example L1E06 - Fix Leading Zero Bug with Conditions
Hussein Nasser
Stateful vs Stateless Applications (Explained by Example)
Hussein Nasser
Javascript By Example L1E07 - Running our Calculator on the Mobile Phone
Hussein Nasser
Advice for New Software Engineers and Developers
Hussein Nasser
Why JSON is so Popular?
Hussein Nasser
Building Scalable Software - SLA, HS, VS
Hussein Nasser
Vlog (Istanbul) - Datacenter Proximity
Hussein Nasser
Should Software Engineers Learn Bleeding-Edge Technologies?
Hussein Nasser
Do Developers Build Bad User Interfaces/Experience?
Hussein Nasser
Learn By Doing.
Hussein Nasser
I Wrote Bad Front-End Code That Broke Chrome
Hussein Nasser
My Story
Hussein Nasser
Vlog - Horizontal vs Vertical Scaling
Hussein Nasser
Can User Experience Help Build Better Rest API?
Hussein Nasser
Reverse engineering Instagram in flight mode
Hussein Nasser
The Benefits of the 3-Tier Architecture (e.g. REST API)
Hussein Nasser
Stateless v. Stateful Architecture (Podcast)
Hussein Nasser
The evolution from virtual machines to containers
Hussein Nasser
Proxy vs. Reverse Proxy (Explained by Example)
Hussein Nasser
Canary Deployment (Explained by Example)
Hussein Nasser
No Excuses
Hussein Nasser
Synchronous vs Asynchronous Applications (Explained by Example)
Hussein Nasser
What is an Asynchronous service?
Hussein Nasser
Difference between Client Polling vs Server Push in Notifications
Hussein Nasser
Software vs. Hardware AdBlockers (Explained by Example)
Hussein Nasser
HTTP Caching with E-Tags - (Explained by Example)
Hussein Nasser
Simple Object Access Protocol Pros and Cons (Explained by Example)
Hussein Nasser
Nodejs Express "Hello, World"
Hussein Nasser
Reverse Engineering Instagram feed
Hussein Nasser
Popup Modal Dialog with Javascript and HTML
Hussein Nasser
MIME and Media Type sniffing explained and the type of attacks it leads to
Hussein Nasser
More on: Docker & Containers
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
What OOP Actually Buys You (And Why “Real World Modeling” Is a Lie)
Medium · Programming
Data Partitioning in System Design: Why Every Scalable Application Depends on It
Medium · Programming
Why Realtime Collaboration Is Harder Than It Looks?
Medium · JavaScript
Podcast: Architectural Patterns: Moving Beyond Cloud-Native to Local-First - Insights from Adam Wiggins
InfoQ AI/ML
🎓
Tutor Explanation
DeepCamp AI