/Dockerized-Rails-PostgreSQL

Rails app with PostgreSQL dockerized using Compose :whale:

Primary LanguageRuby

enter image description here

Sample dockerized Rails app with PostgreSQL

This repo contains the source code for a dockerized sample Rails app in its own isolated container along with another isolated container for persisting data into PostgreSQL database.

To play with it just pull the docker image and run it with Docker Compose:

Pull docker image

DockerHub Registry: https://hub.docker.com/repository/docker/ingmarsk/rails-sample

docker pull ingmarsk/rails-sample

Run Rails + Postgres services all-in-one

docker-compose up

Then visit http://localhost:3005/

To apply codebase changes

docker-compose build
docker-compose up

To stop the app

docker-compose down

To remove the image

docker rmi ingmarsk/rails-sample

Visualize persisted data on TablePlus

All Postgres data from the rails app is persisted in a volume from the host machine so the web and database services can be rebuild without data loss.

To visualise the data, you can connect to the running postgres container rails-sample_db_1 which is mapped to the same port Postgres uses in the host machine: 5432

You can check it by running docker ps:

enter image description here

Open up a new TablePlus PostgreSQL Conenction:

  • Name: docker-sample-app-development
  • Tag: local
  • Host/Socker: 0.0.0.0
  • Port: 5432
  • User: postgres
  • Password: password
  • Database: myapp_development