0% found this document useful (0 votes)
6 views2 pages

Essential Docker Commands for PostgreSQL

The document provides a comprehensive guide on various Docker commands for managing PostgreSQL and Redis containers, including pulling images, running and stopping containers, and managing volumes. It also covers Docker networking and the use of Docker Compose for orchestrating multiple containers. Key commands include 'docker run', 'docker ps', and 'docker-compose up', among others.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Essential Docker Commands for PostgreSQL

The document provides a comprehensive guide on various Docker commands for managing PostgreSQL and Redis containers, including pulling images, running and stopping containers, and managing volumes. It also covers Docker networking and the use of Docker Compose for orchestrating multiple containers. Key commands include 'docker run', 'docker ps', and 'docker-compose up', among others.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

docker pull image_name(postgres/redis) pull image

docker images  docker images list

docker run -e POSTGRES_PASSWORD=password postgres  run postgres container

docker ps  list of running containers

docker stop container_id  stop container

docker ps –a  all running and non-running containers

docker start container_id  run existing container

docker logs container_id  see container logs

docker exec -it container_name psql -U postgres  Connect to PostgreSQL Database inside Docker Container
docker run --name container_name -e POSTGRES_PASSWORD=password postgres  running container with
container name
docker run -d --name alibou-postgres-deatched -e POSTGRES_PASSWORD=password postgres  running
container with container name in detached mode
docker rm container_id remove(delete) container
docker rmi container_id  delete image
docker run --name postgres-sql -e POSTGRES_PASSWORD=password -v
/Users/Muhammadali/docker/volumes/postgres/data:/var/lib/postgres/data postgres --- run container with
volume

docker run --name postgres-sql-anonymous -e POSTGRES_PASSWORD=password -v /var/lib/postgres/data


postgres  anonymous volume

docker run --name postgres-sql-named -e POSTGRES_PASSWORD=password -v


named_volume:/var/lib/postgresql/data postgres  named volume

docker run --name postgres-sql -p 5433:5432 -d -e POSTGRES_PASSWORD=password -v


/Users/Muhammadali/docker/volumes/postgres/data:/var/lib/postgres/data postgres  exposing port for
container on your local machine

docker run --name postgres-sql -p 5433:5432 -d -e POSTGRES_PASSWORD=password -e


POSTGRES_USER=username -e POSTGRES_DB=demo_db -v
/Users/Muhammadali/docker/volumes/postgres/data:/var/lib/postgres/data postgres  running postgres
container
docker build .  create docker image from Dockerfile
docker build -t <name> . -> create docker image from Dockerfile with name
docker network ls  list of networks
docker network create network_name  create network
docker network connect network_name container_name  adding running container to network
docker run --net network_name image_name  running container with network

docker-compose up  run all containers in docker-compose file


docker-compose down stop and remove all the containers in docker-compose file
docker-compose up –d  run containers in detached mode (terminal will not be blocked)

You might also like