Arjun Krishna

2 minute read

I keep forgetting how to setup a postgres instance on local docker on windows 10 machine. I have to search it everytime. I am adding the steps here for myself.

Two links I found useful this time were

postgres container setup

setup

--default driver is local so it persists on your local machine. 
--I was not able to resolve a permission error while mapping my local folder to docker's internal postgres/data folder
--this worked so left it as is and moved on.

docker create -v /var/lib/postgresql/data --name PostgresData alpine

docker run -p 5432:5432 --name postgresContainer -e POSTGRES_PASSWORD=postgres -d --volumes-from PostgresData postgres

-- you can use dpage version... I used this older version.
--https://hub.docker.com/r/meedan/pgadmin/dockerfile
docker run -v pgadmin4:/home/pgadmin/.pgadmin -p 5050:5050 --link postgresContainer:postgresContainer  --name pgadmin -d meedan/pgadmin

navigate to pgadmin website

http://localhost:5050
admin@pgadmin.org
pgadmin

Add server, and use postgresContainer as hostname, postgres as user, and postgres as password.

sequence in which to start and stop the containers

--START
docker start postgresContainer
docker start PostgresData
docker start pgadmin

--STOP
docker stop postgresContainer
docker stop PostgresData
docker stop pgadmin

I was using ef core in my app, just added them here. Will remove this later.


--dotnet tool install --global dotnet-ef --version 3.0.0

dotnet ef Migrations add initial
--dotnet ef migrations remove
dotnet ef database update