I have Postgres installed on our Ubuntu 22.04 server in which the OS & Postgres both reside on a 1TB SSD. I have been evaluating ERP programs & due to the different supporting programs they use to run, such as Python or PHP, I installed Docker to run them in their separate containers. I have a couple extra 2TB hard drives installaed as well & so moved Docker to one of them to occupy the entire hard drive.
I am a new user of Docker and after reading through a lot of the docs, I went through the motions of performing a pull of some of these ERP packages. Some actually install a version of Postgres or MariieDB which make it straight-forward to evaluate but one in particular states that it requires a running Postgres server which I took to it could use what I already have installed on the host OS.
I read a post here about something similar & stating to add the IP address of the server into the run line. This is the run line to be used after running the pull of the image which comes from https://hub.docker.com/r/flectrahq/flectra
docker run -d -e POSTGRES_USER=flectra -e POSTGRES_PASSWORD=flectra --name db postgres:12
Not sure how to create the link in this statement so it knows that the database it needs is located from the link .
I read the question three times, because the description was not clear to me. If you run postgres on the host, yes, you need to use the IP address of the host from containers to connect to the database.
Was this the questions? If not, please, share an error message and where you get that.
Pretty much yes. I do not understand how to tell the app where to loook for Postgres. In the docker run statement I provided, it is using what appears to be some environment variables along with specifiying the name of the database to use, I just don’t understand how to incorpoarte how to use the IP address of the server.
You shared the docker run command of a postgres server, but you run the postgres on the host, so that is irrelevant.
If you need to specifiy the IP address in the flectra container, the image description you linked mentions it
Environment Variables Tweak these environment variables to easily connect to a postgres server:
- HOST: The address of the postgres server. If you used a postgres container, set to the name of the container. Defaults to db.
- PORT: The port the postgres server is listening to. Defaults to 5432.
- USER: The postgres role with which Flectra will connect. If you used a postgres container, set to the same value as POSTGRES_USER. Defaults to flectra.
- PASSWORD: The password of the postgres role with which Flectra will connect. If you used a postgres container, set to the same value as POSTGRES_PASSWORD. Defaults to flectra.
So just use
-e HOST=22.214.171.124 as a parameter of Docker run.
docker run -p 7073:7073 --name flectra -e HOST=126.96.36.199 -e USER=user -e PASSWORD=password -t flectrahq/flectra
Ahhh, I get it. Thanks, that helps.