Remember to create the network first
docker network create db
Then create the postgres
docker run --name db \ -p 5432:5432 --network=db \ -v "$PWD:/var/lib/postgresql/data" \ -e POSTGRES_PASSWORD=password \ -d postgres:alpine
Easy copy directly to the terminal
docker run --name srna-db -p 5432:5432 --network=db -v "$PWD:/var/lib/postgresql/data" -e POSTGRES_PASSWORD=password -d postgres:alpine
This one is good for checking our database from the terminal, remember to change the network for the name of your network also the name db for the name of your postgres database container.
docker run -it --rm --network=db postgres:alpine \ psql -h db -U postgres
Easy copy directly to the terminal
docker run -it --rm --network=db postgres:alpine psql -h db -U postgres