Skip to main content

Command Palette

Search for a command to run...

Run Postgres on docker

Published
1 min readView as Markdown

Prerequisite

  1. Install docker
  2. Install docker-compose

Deploying Postgres Container

We will create a docker-compose.yml configured with postgres

OR

Run the following command to run postgres docker-container

docker-compose up -d

OR

docker stack deploy

To check the services runing use

docker ps -a # to checlk the services running
docker logs postgress-service

Import/Restore SQL

Create a .sql file

cat create-databases-dev.sql | docker exec -i postgress-service psql -U test

Export/Backup SQL

docker exec -t -u test postgress-service pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql

If you want to go with adminer follow use the below docker-compose file

Postgres with adminer UI

Reference

https://github.com/JinnaBalu/postgreSQL

[postgres - Docker Hub
The PostgreSQL object-relational database system provides reliability and data integrity.hub.docker.com](https://hub.docker.com//postgres "https://hub.docker.com//postgres")

[Adminer - Database management in a single PHP file
Adminer (formerly phpMinAdmin) is a full-featured database management tool written in PHP. Conversely to phpMyAdmin, it…www.adminer.org](http://www.adminer.org/ "http://www.adminer.org/")

More from this blog

jinnabaalu

47 posts

Jinna Baalu | Infrastructure Automation