{"id":152521,"date":"2024-02-19T22:30:45","date_gmt":"2024-02-19T19:30:45","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=152521"},"modified":"2024-07-08T19:45:35","modified_gmt":"2024-07-08T16:45:35","slug":"how-to-run-postgresql-server-in-docker-container","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/how-to-run-postgresql-server-in-docker-container\/","title":{"rendered":"How To Run PostgreSQL Server in Docker Container"},"content":{"rendered":"\n<p>PostgreSQL is an open source and enterprise-class relational database system with the support for SQL and JSON querying. PostgreSQL has the backing of more than 20 years of community development. This guarantees the highest levels of integrity, performance, and resilience. The most common application of PostgreSQL is in data warehouse for mobile, web and analytics applications. PostgreSQL comes with a set of features such as asynchronous replication, online\/hot backups, nested transactions, among many other features.<\/p>\n\n\n\n<p>The most common method of installing <a href=\"https:\/\/computingforgeeks.com\/installing-postgresql-database-server-on-ubuntu\/\">PostgreSQL database server<\/a> is from OS package repositories. The <strong>.deb <\/strong>for Debian based systems and <strong>.rpm <\/strong>package for RHEL based systems. The alternative method of running PostgreSQL is inside a container. This gives a clean system state and highest level of portability. In this blog post we focus on installation and running of PostgreSQL database server in Docker Container.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Docker Engine<\/h2>\n\n\n\n<p>Follow the steps provided in our article below to setup Docker environment on your Linux system. Windows and macOS users can user GUI based tools such as Docker Desktop and Portainer.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/computingforgeeks.com\/solve-error-package-docker-ce-stable-requires-container-selinux\/\" target=\"_blank\" rel=\"noreferrer noopener\">How To Install Docker Engine on Linux Systems<\/a><\/li>\n<\/ul>\n\n\n\n<p>After the installation confirm by checking the version release.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">docker --version<\/mark>\nDocker version 25.0.3, build 4debf41<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Create Compose file for PostgreSQL<\/h2>\n\n\n\n<p>Create data directory for PostgreSQL database<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir ~\/postgresql &amp;&amp; cd ~\/postgresql<\/code><\/pre>\n\n\n\n<p>Create Compose file that will define how the contaier should be created.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim docker-compose.yml<\/code><\/pre>\n\n\n\n<p>Next we define the contents of the YAM file. The container <a href=\"https:\/\/hub.docker.com\/_\/postgres\/tags?page=1\" target=\"_blank\" rel=\"noreferrer noopener\">images on Docker Hub<\/a> is what we&#8217;re using to create a running instance of PostgreSQL server. Database data will be stored in the local directory <strong><em>.\/pgdata<\/em><\/strong>.<\/p>\n\n\n\n<p>We also create a container that is running <a href=\"https:\/\/www.adminer.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Admirer PostgreSQL<\/a> web based management tool.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PostgreSQL 16<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>services:\n  db:\n    image: postgres:16-bookworm\n    restart: always\n    environment:\n      POSTGRES_PASSWORD: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">StrongPassword01<\/mark>\n    volumes:\n      - .\/pgdata:\/var\/lib\/postgresql\/data\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PostgreSQL 15<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>services:\n  db:\n    image: postgres:15-bookworm\n    restart: always\n    environment:\n      POSTGRES_PASSWORD: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">StrongPassword01<\/mark>\n    volumes:\n      - .\/pgdata:\/var\/lib\/postgresql\/data\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PostgreSQL 14<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>services:\n  db:\n    image: postgres:14-bookworm\n    restart: always\n    environment:\n      POSTGRES_PASSWORD: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">StrongPassword01<\/mark>\n    volumes:\n      - .\/pgdata:\/var\/lib\/postgresql\/data\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PostgreSQL 13<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>services:\n  db:\n    image: postgres:13-bookworm\n    restart: always\n    environment:\n      POSTGRES_PASSWORD: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">StrongPassword01<\/mark>\n    volumes:\n      - .\/pgdata:\/var\/lib\/postgresql\/data\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PostgreSQL 12<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>services:\n  db:\n    image: postgres:12-bookworm\n    restart: always\n    environment:\n      POSTGRES_PASSWORD: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">StrongPassword01<\/mark>\n    volumes:\n      - .\/pgdata:\/var\/lib\/postgresql\/data\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PostgreSQL 11<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>services:\n  db:\n    image: postgres:11-bookworm\n    restart: always\n    environment:\n      POSTGRES_PASSWORD: <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">StrongPassword01<\/mark>\n    volumes:\n      - .\/pgdata:\/var\/lib\/postgresql\/data\n\n  adminer:\n    image: adminer\n    restart: always\n    ports:\n      - 8080:8080<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Running PostgreSQL server in container<\/h2>\n\n\n\n<p>Next we start the container by running the compose up commands. The <code>-d<\/code> option keep it running in detached mode (background) without active interactive session.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">docker compose up -d<\/mark>\n&#91;+] Running 22\/22\n <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> adminer <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">7 layers<\/mark> &#91;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-green-cyan-color\">\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff<\/mark>]      0B\/0B      Pulled                                                                                                                                            <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">11.0s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 09e2bc8a597c Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">0.9s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 092a59d5d649 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">0.7s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> e4dca1b56763 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">0.4s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 378feffe5197 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">0.8s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 3bd4de3ac847 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">1.1s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 44d5566ceca7 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">1.1s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 3dafa7b9d4fc Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">1.3s<\/mark>\n <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> db <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">13 layers<\/mark> &#91;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-green-cyan-color\">\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff<\/mark>]      0B\/0B      Pulled                                                                                                                                          <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">13.5s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 1f7ce2fa46ab Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">1.8s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> e75b44f17b07 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">1.6s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> d601ea737a84 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">2.9s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 0f4fcee3f93d Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">2.1s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 428f7aff61bc Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">2.6s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 7787ed5ab4f3 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">3.0s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 3d2b66cffddc Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">3.3s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> e7dee0dd847b Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">3.3s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> a24060178bac Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">5.8s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 0eb290c85bd2 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">4.2s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> 88b80c4fe471 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">3.9s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> eac33d14a11e Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">4.4s<\/mark>\n   <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> d40b681a9814 Pull complete                                                                                                                                                                  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">4.9s<\/mark>\n&#91;+] Running 2\/3\n \u280b Network postgresql_default      Created                                                                                                                                                       <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">1.0s<\/mark>\n <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> Container postgresql-adminer-1  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-green-cyan-color\">Started<\/mark>                                                                                                                                                       <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">0.8s<\/mark>\n <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">\u2714<\/mark> Container postgresql-db-1       <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-light-green-cyan-color\">Started<\/mark>                                                                                                                                                       <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">0.7s<\/mark><\/code><\/pre>\n\n\n\n<p>Confirm status of the container by executing the <a href=\"https:\/\/computingforgeeks.com\/install-docker-and-docker-compose-on-kali-linux\/\">docker compose<\/a> with <code>ps<\/code> flag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">docker compose ps<\/mark>\nNAME                   IMAGE                  COMMAND                  SERVICE   CREATED         STATUS         PORTS\npostgresql-adminer-1   adminer                \"entrypoint.sh php -\u2026\"   adminer   5 minutes ago   Up 5 minutes   0.0.0.0:8080-&gt;8080\/tcp, :::8080-&gt;8080\/tcp\npostgresql-db-1        postgres:11-bookworm   \"docker-entrypoint.s\u2026\"   db        5 minutes ago   Up 5 minutes   5432\/tcp<\/code><\/pre>\n\n\n\n<p>To enter container shell, run;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">docker exec -ti postgresql-db-1 bash<\/mark>\nroot@a79ad82fd433:\/#<\/code><\/pre>\n\n\n\n<p>The version of PostgreSQL server can be checked using <code>psql -V<\/code> command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@a79ad82fd433:\/# <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">psql -V<\/mark>\npsql (PostgreSQL) 11.22 (Debian 11.22-1.pgdg120+1)<\/code><\/pre>\n\n\n\n<p>From there you can start <code>psql<\/code> which is a terminal-based front-end to PostgreSQL.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@a79ad82fd433:\/# <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">su - postgres<\/mark>\npostgres@a79ad82fd433:~$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">psql<\/mark>\npsql (11.22 (Debian 11.22-1.pgdg120+1))\nType \"help\" for help.\n\npostgres=#<\/code><\/pre>\n\n\n\n<p>We can create a test user and database;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Database user: <strong>computingforgeeks<\/strong><\/li>\n\n\n\n<li>Database name: <strong>mywebsite<\/strong><\/li>\n\n\n\n<li>Password: <strong>Str0ngPassw0rd<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">CREATE USER<\/mark> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">computingforgeeks<\/mark> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">WITH PASSWORD<\/mark> '<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-cyan-blue-color\">Str0ngPassw0rd<\/mark>';\nCREATE ROLE\n\npostgres=#<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> CREATE DATABASE <\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">mywebsite<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> WITH OWNER = '<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">computingforgeeks<\/mark>';<\/mark>\nCREATE DATABASE<\/code><\/pre>\n\n\n\n<p>To exit the PostgreSQL and container shell use the <code>exit<\/code> command three times.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">exit<\/mark>\npostgres@a79ad82fd433:~$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">exit<\/mark>\nlogout\nroot@a79ad82fd433:\/# <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">exit<\/mark>\nexit\n&#91;root@rocky8 postgresql]#<\/code><\/pre>\n\n\n\n<p>Database data will be stored in <strong><em>.\/pgdata<\/em><\/strong> as defined in the compose file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> $ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">ls -1 pgdata\/<\/mark>\nbase\nglobal\npg_commit_ts\npg_dynshmem\npg_hba.conf\npg_ident.conf\npg_logical\npg_multixact\npg_notify\npg_replslot\npg_serial\npg_snapshots\npg_stat\npg_stat_tmp\npg_subtrans\npg_tblspc\npg_twophase\nPG_VERSION\npg_wal\npg_xact\npostgresql.auto.conf\npostgresql.conf\npostmaster.opts\npostmaster.pid<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Accessing Admirer dashboard<\/h2>\n\n\n\n<p>Open your web browser on <strong>http:\/\/ServerIP:8080.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"441\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-1024x441.png\" alt=\"\" class=\"wp-image-152558\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-1024x441.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-300x129.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-768x331.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-1536x662.png 1536w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-2048x882.png 2048w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-696x300.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-1068x460.png 1068w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-975x420.png 975w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Login as user, database and with the password.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"466\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-1024x466.png\" alt=\"\" class=\"wp-image-152561\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-1024x466.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-300x137.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-768x349.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-1536x699.png 1536w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-2048x932.png 2048w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-696x317.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-1068x486.png 1068w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-02-923x420.png 923w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You will get a dashboard similar to one shown below. From here you can manage your database &#8211; create tables, functions, views, import data e.t.c.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"462\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-1024x462.png\" alt=\"\" class=\"wp-image-152562\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-1024x462.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-300x135.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-768x347.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-1536x693.png 1536w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-2048x924.png 2048w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-696x314.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-1068x482.png 1068w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/02\/Run-PosgreSQL-Docker-Container-03-931x420.png 931w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>By running PostgreSQL database in a container you enjoy the efficiency of administering it. The other benefits of containerization range from portability, isolation to scalability. You can lift the container image with data and run in a separate host within seconds. Deciding whether to adopt containerized database boils down to your use preference.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PostgreSQL is an open source and enterprise-class relational database system with the support for SQL and JSON querying. PostgreSQL has the backing of more than 20 years of community development. This guarantees the highest levels of integrity, performance, and resilience. The most common application of PostgreSQL is in data warehouse for mobile, web and analytics &#8230; <a title=\"How To Run PostgreSQL Server in Docker Container\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/how-to-run-postgresql-server-in-docker-container\/\" aria-label=\"Read more about How To Run PostgreSQL Server in Docker Container\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":145173,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[316,461,27,299,37631],"tags":[39006],"class_list":["post-152521","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-containers","category-databases","category-docker","category-how-to","category-postgresql","tag-postgresql-server-in-docker-container"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/152521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=152521"}],"version-history":[{"count":0,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/152521\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/145173"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=152521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=152521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=152521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}