Spin up a Postgres Instance & PGADMIN with Docker

Hussein Nasser · Advanced ·🏗️ Systems Design & Architecture ·6y ago

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 Extending ArcObjects (IGeometry) - 01 - Getting Started
Extending ArcObjects (IGeometry) - 01 - Getting Started
Hussein Nasser
2 Extending ArcObjects  (IGeometry) - 02 - The Document, The Map and The Layers
Extending ArcObjects (IGeometry) - 02 - The Document, The Map and The Layers
Hussein Nasser
3 Channel Update - New Book, New Job, New Videos
Channel Update - New Book, New Job, New Videos
Hussein Nasser
4 Learn Programming with VB.NET - 01 - Getting Started
Learn Programming with VB.NET - 01 - Getting Started
Hussein Nasser
5 Learn Programming with VB.NET - 02 - Classes and Objects (Part 1)
Learn Programming with VB.NET - 02 - Classes and Objects (Part 1)
Hussein Nasser
6 Learn Programming with VB.NET - 03 - Classes and Objects (Part 2)
Learn Programming with VB.NET - 03 - Classes and Objects (Part 2)
Hussein Nasser
7 Learn Programming with VB.NET - 04 - User Interface
Learn Programming with VB.NET - 04 - User Interface
Hussein Nasser
8 Learn Programming with VB.NET - 05 - By Value v. By Reference
Learn Programming with VB.NET - 05 - By Value v. By Reference
Hussein Nasser
9 Learn Programming with VB.NET - 06 - Variable size, 32 bit vs 64 bit
Learn Programming with VB.NET - 06 - Variable size, 32 bit vs 64 bit
Hussein Nasser
10 Learn Programming with VB.NET - 07 - Conditional Statements
Learn Programming with VB.NET - 07 - Conditional Statements
Hussein Nasser
11 Learn Programming with VB.NET - 08 - Inheritance
Learn Programming with VB.NET - 08 - Inheritance
Hussein Nasser
12 Learn Programming with VB.NET - 09 - Strategy Design Pattern
Learn Programming with VB.NET - 09 - Strategy Design Pattern
Hussein Nasser
13 Learn Programming with VB.NET - 10 -  How did I learn programming
Learn Programming with VB.NET - 10 - How did I learn programming
Hussein Nasser
14 IGeometry 2016 Retrospective - Channel Update
IGeometry 2016 Retrospective - Channel Update
Hussein Nasser
15 Javascript by Example - The Vook
Javascript by Example - The Vook
Hussein Nasser
16 Vlog - Keep your servers close and your database closer
Vlog - Keep your servers close and your database closer
Hussein Nasser
17 Vlog - Client/Server Programming Languages
Vlog - Client/Server Programming Languages
Hussein Nasser
18 Javascript By Example L1E01 - Getting Started
Javascript By Example L1E01 - Getting Started
Hussein Nasser
19 Persistent Connections (Pros and Cons)
Persistent Connections (Pros and Cons)
Hussein Nasser
20 Javascript By Example L1E02 - Building the Calculator Interface
Javascript By Example L1E02 - Building the Calculator Interface
Hussein Nasser
21 Happy new Year from IGeometry!
Happy new Year from IGeometry!
Hussein Nasser
22 Synchronous v. Asynchronous
Synchronous v. Asynchronous
Hussein Nasser
23 Javascript By Example L1E03 - Displaying the Digits on Calculator Screen
Javascript By Example L1E03 - Displaying the Digits on Calculator Screen
Hussein Nasser
24 Show Your Work. Blog, Vlog, Write, Create and Develop!
Show Your Work. Blog, Vlog, Write, Create and Develop!
Hussein Nasser
25 Relational Database Atomicity Explained By Example
Relational Database Atomicity Explained By Example
Hussein Nasser
26 Javascript By Example L1E04 - Operators, All Clear with Arrow Functions
Javascript By Example L1E04 - Operators, All Clear with Arrow Functions
Hussein Nasser
27 What Comes First, User Experience or Software Architecture?
What Comes First, User Experience or Software Architecture?
Hussein Nasser
28 Javascript By Example L1E05 -  Evaluate the Calculator Expressions with eval
Javascript By Example L1E05 - Evaluate the Calculator Expressions with eval
Hussein Nasser
29 Fastest Way to Learn Programming Language or Technology
Fastest Way to Learn Programming Language or Technology
Hussein Nasser
30 Javascript By Example L1E06 -  Fix Leading Zero Bug with Conditions
Javascript By Example L1E06 - Fix Leading Zero Bug with Conditions
Hussein Nasser
31 Stateful vs Stateless Applications (Explained by Example)
Stateful vs Stateless Applications (Explained by Example)
Hussein Nasser
32 Javascript By Example L1E07 - Running our Calculator on the Mobile Phone
Javascript By Example L1E07 - Running our Calculator on the Mobile Phone
Hussein Nasser
33 Advice for New Software Engineers and Developers
Advice for New Software Engineers and Developers
Hussein Nasser
34 Why JSON is so Popular?
Why JSON is so Popular?
Hussein Nasser
35 Building Scalable Software - SLA, HS, VS
Building Scalable Software - SLA, HS, VS
Hussein Nasser
36 Vlog (Istanbul) - Datacenter Proximity
Vlog (Istanbul) - Datacenter Proximity
Hussein Nasser
37 Should Software Engineers Learn Bleeding-Edge Technologies?
Should Software Engineers Learn Bleeding-Edge Technologies?
Hussein Nasser
38 Do Developers Build Bad User Interfaces/Experience?
Do Developers Build Bad User Interfaces/Experience?
Hussein Nasser
39 Learn By Doing.
Learn By Doing.
Hussein Nasser
40 I Wrote Bad Front-End Code That Broke Chrome
I Wrote Bad Front-End Code That Broke Chrome
Hussein Nasser
41 My Story
My Story
Hussein Nasser
42 Vlog - Horizontal vs Vertical Scaling
Vlog - Horizontal vs Vertical Scaling
Hussein Nasser
43 Can User Experience Help Build Better Rest API?
Can User Experience Help Build Better Rest API?
Hussein Nasser
44 Reverse engineering Instagram in flight mode
Reverse engineering Instagram in flight mode
Hussein Nasser
45 The Benefits of the 3-Tier Architecture (e.g. REST API)
The Benefits of the 3-Tier Architecture (e.g. REST API)
Hussein Nasser
46 Stateless v. Stateful Architecture (Podcast)
Stateless v. Stateful Architecture (Podcast)
Hussein Nasser
47 The evolution from virtual machines to containers
The evolution from virtual machines to containers
Hussein Nasser
48 Proxy vs. Reverse Proxy (Explained by Example)
Proxy vs. Reverse Proxy (Explained by Example)
Hussein Nasser
49 Canary Deployment (Explained by Example)
Canary Deployment (Explained by Example)
Hussein Nasser
50 No Excuses
No Excuses
Hussein Nasser
51 Synchronous vs Asynchronous Applications (Explained by Example)
Synchronous vs Asynchronous Applications (Explained by Example)
Hussein Nasser
52 What is an Asynchronous service?
What is an Asynchronous service?
Hussein Nasser
53 Difference between Client Polling vs Server Push in Notifications
Difference between Client Polling vs Server Push in Notifications
Hussein Nasser
54 Software vs. Hardware AdBlockers (Explained by Example)
Software vs. Hardware AdBlockers (Explained by Example)
Hussein Nasser
55 HTTP Caching with E-Tags -  (Explained by Example)
HTTP Caching with E-Tags - (Explained by Example)
Hussein Nasser
56 Simple Object Access Protocol Pros and Cons (Explained by Example)
Simple Object Access Protocol Pros and Cons (Explained by Example)
Hussein Nasser
57 Nodejs Express "Hello, World"
Nodejs Express "Hello, World"
Hussein Nasser
58 Reverse Engineering Instagram feed
Reverse Engineering Instagram feed
Hussein Nasser
59 Popup Modal Dialog with Javascript and HTML
Popup Modal Dialog with Javascript and HTML
Hussein Nasser
60 MIME and Media Type sniffing explained and the type of attacks it leads to
MIME and Media Type sniffing explained and the type of attacks it leads to
Hussein Nasser

This video teaches how to spin up a Postgres instance and PGADMIN with Docker, covering topics such as containerization, database management, and system design. By following the steps outlined in the video, viewers can learn how to design and configure a system with containerized databases.

Key Takeaways
  1. Open a terminal window and run the command to spin up a Postgres instance with Docker
  2. Configure environment variables for the PGADMIN container
  3. Run the command to spin up the PGADMIN container
  4. Access the PGADMIN web interface and connect to the Postgres database
  5. Create a new server in PGADMIN and connect to the second Postgres instance
💡 Using Docker to containerize databases and applications simplifies system design and configuration, allowing for easy deployment and management of multiple instances.

Related AI Lessons

What OOP Actually Buys You (And Why “Real World Modeling” Is a Lie)
Learn the actual benefits of Object-Oriented Programming (OOP) and why 'real world modeling' is a misconception
Medium · Programming
Data Partitioning in System Design: Why Every Scalable Application Depends on It
Learn how data partitioning enables scalable applications to handle growth without failing
Medium · Programming
Why Realtime Collaboration Is Harder Than It Looks?
Realtime collaboration is a complex distributed systems problem that requires careful engineering, not just a simple UI feature
Medium · JavaScript
Podcast: Architectural Patterns: Moving Beyond Cloud-Native to Local-First - Insights from Adam Wiggins
Learn how to design local-first architectures that combine cloud-based collaboration with local software performance and data ownership
InfoQ AI/ML
Up next
Retracing It All With My Son
Ginny Clarke
Watch →