simples way to run postgres in docker
This repo is just do store a simple way to run postgres and pgweb with docker
To run this in your machine you will need to have Docker and Docker Compose installed.
Cloning the Repository
$ git clone https://github.com/codingwithmath/postgres-docker
$ cd postgres-docker
in our docker-compose.yml
file we'll have our postgres image. It's important to noticy that we configure our database name, user and password:
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- TZ=GMT
if you need to make changes in the file, that's the moment.
If you have your enviorement properly configured you can run:
$ sudo docker-compose up
or
$ sudo docker-compose up -d
after your containers is up and running you'll be able to execute your migrations
first, we are going to copy our migrations to the data/postgres
folder created when we init our containers
$ sudo cp migrations/{YOUR_MIGRATIONS} data/postgres
in my case:
$ sudo cp migrations/*up.sql data/postgres
after that, we can run our migrations:
$ sudo docker-compose exec postgres psql -U {YOUR_POSTGRES_USER} -d {YOUR_POSTGRES_DB} -1 -f /var/lib/postgresql/data/YOUR_MIGRATION.sql
in my case:
$ sudo docker-compose exec postgres psql -U postgres -d postgres -1 -f /var/lib/postgresql/data/001_create_table_up.sql
after running all comands above you'll can now see everything in http://localhost:8081