How To Run the Latest Version of PostgreSQL Using Docker
One can rely on the PostgreSQL object-relational database system to ensure data integrity, making the workflow of DevOps Developers and Engineers more productive.
Join the DZone community and get the full member experience.
Join For FreeWhat Is PostgreSQL?
PostgreSQL, commonly referred to as "Postgres," is an ORDBMS that prioritizes extensibility and adherence to standards. Its main purpose as a database server is to securely store data and retrieve it upon request from software applications, whether they are on the same machine or on a network. Postgres is capable of handling workloads of varying sizes, ranging from small single-machine applications to large, internet-facing applications with multiple users. Additionally, recent versions of Postgres offer database replication for enhanced security and scalability.
PostgreSQL is a highly versatile database management system that adheres to the SQL:2011 standard and follows the ACID compliance model, which ensures reliable and accurate data transactions. It utilizes multi-version concurrency control (MVCC) to avoid locking issues and provides immunity to dirty reads and full serializability. PostgreSQL supports a wide range of SQL queries using advanced indexing methods not available in other databases. It also offers features such as updateable views, materialized views, triggers, foreign keys, support functions, and stored procedures. Furthermore, PostgreSQL is highly extensible and offers a plethora of third-party extensions. It can also migrate data from major proprietary and open-source databases using standard SQL support and migration tools. The software's extensibility allows it to emulate many proprietary extensions through built-in and third-party open-source compatibility extensions, such as those for Oracle.
How to Setup WSL2 and Install Docker Desktop on Windows 10
In order to properly configure Docker and get PostgreSQL to work, we need to follow a process:
- Search for Turn Windows features on or off
- Tick Windows Subsystem for Linux and Virtual Machine Platform
- Now restart the PC
- Open run and type winver to check the build version
- To update to WSL 2, you must be running Windows 10
- For x64 systems: Version 1903 or later, with Build 18362 or later.
- For ARM64 systems: Version 2004 or later, with Build 19041 or later.
- Download the Linux kernel update package
- Open PowerShell and Set WSL 2 as your default version
wsl --set-default-version 2
8. Check the available valid Linux distribution by running this command in PowerShell.
wsl -l -o
9. Install your Linux distribution of choice. In this case, I chose Ubuntu 18.04.
wsl --install -d Ubuntu-18.04
10. Run the Ubuntu terminal and enter your UNIX username and UNIX password
11. Install Docker Desktop Installer 4.1.1 and run Docker to start the engine.
How To Install the Latest Version of PostgreSQL
- Go to Docker Hub
- Search for Postgres
- Select the official Docker Image of PostgreSQL
- Run this command to pull Postgres which will be the latest version
docker pull postgres
How to Run PostgreSQL in Docker 4.11
1. Start a Postgres instance by running this command
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
2. Navigate to Docker, and Postgres should be up and running.
Opinions expressed by DZone contributors are their own.
Comments