-
Make a volume where postgres will store its data,
docker volume create pgdata
-
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
-
Using the postgres container interactively,
docker exec -it postgres psql -U username -c "command"
-
Stop the container,
docker container stop postgres
-
Start the container,
docker start postgres
Setting up Postgres with Docker
Making volume, running container, etc.
Published on · 1 min read · 1 view · 1 reading right now
DOCKER
POSTGRES
0 likes
Other articles