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
Ingénieur en Informatique
5 年Thank you; Very informative tutorial!
ITRG Senior PR Manager ??Connecting Journalists with Top Industry Experts
5 年Great video Igal, very informative! And great job on the production as well!
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