Setting up Postgres with Docker

Making volume, running container, etc.

Published on · 1 min read · 1 view · 1 reading right now

DOCKER
POSTGRES
  1. Make a volume where postgres will store its data, docker volume create pgdata

  2. Run postgres docker image, docker run --name postgres -e POSTGRES_USER=username -e POSTGRES_PASSWORD=password -d -p 5432:5432 -v pgdata:/var/lib/postgresql/data postgres:latest

  3. Using the postgres container interactively, docker exec -it postgres psql -U username -c "command"

  4. Stop the container, docker container stop postgres

  5. Start the container, docker start postgres

0 likes

Other articles