Easily Run Postgres in Docker

Easily Run Postgres in Docker

I made a video tutorial with an introduction to running Postgres in Docker. There are plenty of tutorials with lots of theory, so it was important to me to make a hands-on one, with as much useful information as I can pack into a 13 minute video.

All of the software used is free, open source, and cross platform, so if you are rather new to Postgres and/or Docker, I hope that you find it useful (and if you find the pace too slow to your taste, set the speed in your YouTube player to 1.25 or 1.5X):

In this tutorial I use the official Docker image for Postgres from the Docker Hub. The image's page contains all of the available options and tags, and can be found at https://hub.docker.com/_/postgres

The tutorial covers the following topics and commands:

  • Check what containers are already running in the system with the command:
docker ls -a
  • Persisting data by mounting a directory from the host machine
  • Running the official Postgres image from Docker Hub with the command below:
docker container run 
    -d 
    --name=pg 
    -p 5432:5432 
    -e POSTGRES_PASSWORD=secret 
    -e PGDATA=/pgdata
    -v /pgdata:/pgdata
    postgres
  • Connecting to the new Postgres server with `psql` from the host machine (requires password as the connection does not appear to be from localhost inside the container):
psql -h localhost -p 5432 -U postgres
  • Logging into the container and running `bash` inside it with:
docker container exec -it pg bash
  • Logging into the container and running the `psql` client that ships with the image (does not require password as localhost is set to "trust" in `pg_hba.conf`:
docker container exec -it pg psql -U postgres
  • Stopping a container and removing it
  • Performing a Minor Upgrade of Postgres
  • Connecting to the Postgres server from a GUI SQL client
  • Many more tips and details

In the spirit of open source, all of the software and tools I used here are FOSS (Free and Open Source Software), including:

  • Linux, Ubuntu, Gnome, KDE - Operating system and desktop environments
  • Docker - Containerization
  • Postgres - RDBMS
  • DBeaver - GUI SQL client
  • Open Broadcaster Software (OBS) - Screencast recorder
  • Kdenlive - Video Editing software (runs best in KDE)
  • GNU Image Manipulation Program (GIMP) - Image editor
Mohamed Amine GHODHBANE

Ingénieur en Informatique

5 年

Thank you; Very informative tutorial!

Sufyan A.

ITRG Senior PR Manager ??Connecting Journalists with Top Industry Experts

5 年

Great video Igal, very informative! And great job on the production as well!

Igal S.

Software Architect

5 年

I had some time this weekend so it took me about 1.3 days (a day counted as 8 hours) to produce a 13 minute video (most of the time went into editing which is not my forte).? I hope that it turns to be useful. Shay ?? Rowbottom?Sivan Felder?How long does it take you to produce a 13 minute video?? Feels like this was way too long

要查看或添加评论,请登录

Igal S.的更多文章

  • Fraud on LinkedIn! Beware!

    Fraud on LinkedIn! Beware!

    I've been meaning to post this article for some time now. For some reason I am being targeted by scammers, or maybe…

    73 条评论
  • Farewell Windows (it's not you, it's me)

    Farewell Windows (it's not you, it's me)

    Farewell Windows, it's been a great ride but I've outgrown this relationship and it's time for me to move on. People…

    71 条评论
  • Getting Started with Lucee in Docker

    Getting Started with Lucee in Docker

    In this video I show how to get started with Lucee in Docker: I am using the project that I recently published at…

    2 条评论
  • Cockpit - Linux Web Console

    Cockpit - Linux Web Console

    So I installed CentOS 8 in VirtualBox today. Why, are you asking? Because that's what I "do for fun".

    14 条评论
  • I ?? Lucee

    I ?? Lucee

    Last month I gave a talk titled "I Love Lucee" at the Tomcat track of ApacheCon (link to video below though the preview…

    22 条评论
  • Gotta love Postgres Procedural Languages

    Gotta love Postgres Procedural Languages

    I recently had to parse some text that was stored in a Postgres database. The text in each record had multiple lines of…

    5 条评论
  • How to use your regular IP when connected to a VPN

    How to use your regular IP when connected to a VPN

    Consulting for different Enterprise and Government organizations means that each of them requires me to connect to…

    11 条评论
  • Gotta Love Postgres Arrays

    Gotta Love Postgres Arrays

    I recently helped a client migrate their database from SQL Server to Postgres. Some of their tables, e.

    8 条评论
  • time.Format(layout) in Go

    time.Format(layout) in Go

    A common task in programming is to format a point in time in a certain layout that is easily understood by humans or…

    12 条评论
  • The More I Write Go - Episode IV

    The More I Write Go - Episode IV

    Go has become a very popular language in recent years. The fact that it came from Google it a big boost.

    2 条评论

社区洞察

其他会员也浏览了