Cuba requires three things:
- The IDE/IntelliJ/CLI
- A modern browser (Firefox/Chrome/etc)
- A DBMS (like PostgreSQL)
This little guide will help set up Postgresql inside a Docker Container and have CUBA connect to it.
Docker needs to be installed (at time of writing this version:
docker pull postgres
Run postgres container
postgres image successfully, run it into a container while replacing
yoursecretpassword with whatever password you want to set for
postgres. This will also create port forwarding from the host port
5432 to the container port
Note: if you have a different local postgresql instance running on the same port for some reason, you can opt to change the host port to something else like
docker run --name cuba-postgres -e POSTGRES_PASSWORD=yoursecretpassword -d -p 5432:5432 postgres
Get Docker IP
The network between the container and the host are “bridged”. There are a few ways to get the IP address of the docker host and container.
ipconfig should show the docker network connection. Else
docker-machine ip (for Docker Toolbox) or
docker network inspect bridge in the command prompt should show it as well.
ifconfig should show the docker network connection. Else
docker network inspect bridge works too.
Test Database and Connection
SSH into the postgres container:
docker exec -it cuba-postgres bash
Open the PSQL shell:
psql -U postgres
Create a Database :
postgres=# CREATE DATABASE cuba;
Then exit out of the database
\q and container
exit back to host.
Lots of apps out there like HeidiSQL and pgAdmin. Just enter all of the details we gathered here and into there where:
- host is the docker IP address
- port is
- user is
- password is
yoursecretpasswordwhere you set earlier
If you have a
psql client installed, run
psql -d cuba -h <your docker ip xxx.xxx.xx.xxx> -U postgres
Enter password prompt and it works.
Since it works, use the same details for connecting from CUBA to your PostgreSQL.
All the best!