dev-resources.site
for different kinds of informations.
How to run postgres database using docker and docker-compose
Published at
10/3/2023
Categories
postgres
docker
dockercompose
ubuntu
Author
shaikhalamin
Author
12 person written this
shaikhalamin
open
Using docker-compose:
Create a directory postgresql_data.
mkdir postgresql_data
Create docker volume for postgresql_data:
docker volume create postgresql_data
*Now create a docker-compose.yml file and paste the following code: *
version: '3.8'
services:
pg_database:
image: postgres:14.9-alpine
restart: always
volumes:
- ./postgresql_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
ports:
- '5455:5432'
volumes:
postgresql_data:
*Now run: *
docker-compose up --build -d
Install only postgres client for terminal:
sudo apt install postgresql-client
Connect from the terminal to your database:
psql -U postgres -p 5455 -h localhost;
Now create your own database to start working :
create database ecommerce_crud;
*Insert dump sql into database : *
psql -U postgres -p 5455 -h localhost -d nodalnda < nodal_dump_local2024_04_29_20_00.sql
Postgres Basic command:
\l ; is same as show databases in mysql;
\d+ products; is same as show create table products ;
\c morning_fresh_bakery; same as use country_db in mysql;
\dt; show tables in mysql;
\d users describe table;
DROP DATABASE nodalnda WITH (FORCE);
dockercompose Article's
30 articles in total
Want to Learn Docker in Advance Way?
read article
deploy Jenkins using docker compose with production ready
read article
Docker Advance Part 2: Docker Logging
read article
A Simple Guide to Docker Compose & Multi-Container Applications
read article
Dockerize nestjs app with postgres
read article
Tips and Tricks for Docker Compose: Leveraging the override Feature
read article
Dockerize nestjs application with Postgres
read article
RabbitMQ container with Docker Compose
read article
Quick and simple Local WordPress Setup for Lazy Developers
read article
Bug: Docker-compose up?
read article
How to resolve Docker Compose Warning WARN[0000] Found orphan containers
read article
How to resolve Docker Compose Warning WARN[0000] Found orphan containers
read article
How To Set Up Docker SeleniumΒ GRID
read article
How to Ensure Docker Compose Uses Environment Variables from the `.env` File
read article
Essential Docker Commands for Developers
read article
[Docker] How to fix 'host not found in upstream "host.docker.internal"'.
read article
Como configurar imagem Docker(PHP e Nginx) para projetos Laravel com PHP 8.3
read article
Containerize your multi-services app with docker compose
read article
αααααΆαααα»αα’αααΈαααΆαα α’αα αααα»α Docker compose.
read article
Installation of Docker Compose:
read article
MongoDB containers with Docker Compose
read article
An Overview of Docker Compose and its Features.
read article
How to change docker root data directory and why would you want to do that (hint: to optimize space)
read article
Containerize a Web Application using docker compose
read article
O Docker Compose agora tem uma V2, veja como instalar
read article
Vue 2 vite dockerized steps
read article
An Advanced Guide (2) to Docker: Managing Multi-Container Applications π³
read article
How to run mongodb using docker-compose in ubuntu
read article
How to run postgres database using docker and docker-compose
currently reading
Easy Dockerization with Docker INIT
read article
Featured ones: