Deploying Hasura on container app with existing Postgresql Flexible Server - azure-container-apps

How can be deploy Hasura on Container App with postgresql Flexible Server using dockerfile or docker compose.

Related

Deploy Heroku Docker Api (.net core 6 ) image with PostgreSQL

There is postgres Add-ons in Heroku which I want to connect it to my Docker image of my Api with connection string:
_connectionString = Environment.GetEnvironmentVariable("POSTGRESQL_CONNECTION_STRING");
how I can define Environment Variable in postgres to connect [postgres database in Herkou] to my Api docker image?(my api is in .core 6)

Is it possible to configure server for pgadmin in docker-compose instead of configuring it from pgadmin ui

I am running pgadmin and postgres through docker-compose and both are in same network, so I am able to connect to posgtres from pgadmin after configuring the server in pgadmin. If I do docker-compose down, all containers are destroyed so my server configuration in pgadmin will be lost. If I do docker-compose up again, I will have to configure the server from pgadmin ui again. I want to avoid this manual process of configuring server in pgadmin.
Create a volume and mount the volume in the pgadmin container where config is stored (/etc/pgadmin for Linux). Now your changes will be persisted across restarts.
https://docs.docker.com/compose/compose-file/compose-file-v3/#volumes

How can i see PostgreSQL UI in pgAdmin if the db is in Docker?

I have installed one open-source project from docker and that project has a database in PostgreSQL. Now I want to see the database from pgAdmin 4 and when I am trying to connect with "host.docker.internal" I am getting an error see image below.
Simply do mapping port for your PostgreSQL (which is running inside Docker). and from your pgAdmin4 you'll connect using localhost:<mapped_port>
If you're using docker-compose
services:
postgre:
ports:
- "8080:5432"
If you're using docker-cli
docker run postgre -p 8080:5432
Then from pgAdmin4 connect to your database using localhost:8080
I suspect this is a networking issue.
If port mapping does not work as suggested in other answers, try specifying the network as host for your container
If you are using docker run
--net=host
Or use the following on docker compose
network_mode: 'host'

connection refused postgres docker

I made a small application with spring-boot, spring jpa data, that connects to a dockerized postgres instace and it works pretty fine, even if I try to connect via
'psql' to the dockerized postgres instace it works well. The porblem is when I try to dockerize an image's instance of my spring-boot application and I try to link it with the dockerized postegres instance.
The docker command I use is this
docker run -it --link mypgcontainerwithpwd:postgres --name postgresclient1 sprinbootjpa
As a I already mentioned the container mypgcontainerwithpwd is running and reachable either with a local application either via psql
psql -p 5555 postgres postgres
in the jar I'm going to execute the application.properties file looks like this
spring.datasource.url=jdbc:postgresql://localhost:5555/postgres
spring.datasource.username=postgres
spring.datasource.password=password
spring.jpa.generate-ddl=true
During the starting phase an exception is raised up that prints: connection refused localhost-> 5555
The dockerfile that builds the instace looks like this
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD ./SpringJPA-PostgreSQ-0.0.1.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
I'm new to docker and I didn't find anything to fix the issue, I'm running docker on windows 10 with unix containers.
Thanks to all.
In your property file you are stating that postgres is running in the same container as your Spring Boot application (localhost) which is not true as it is running in a different container.
Replace you property by this:
spring.datasource.url=jdbc:postgresql://postgres:5555/postgres
You could also point to the docker bridge ip which usually is 172.17.0.1.
Change -
spring.datasource.url=jdbc:postgresql://localhost:5555/postgres
TO
spring.datasource.url=jdbc:postgresql://postgres:5555/postgres
Since you started the client container with link --link mypgcontainerwithpwd:postgres which means your client will be able to reach your mypgcontainerwithpwd container using alias postgres. localhost means your client container itself & not mypgcontainerwithpwd.
This works, but I just want to emphasize Vivek's point that "postgres" comes from the container name and not the userID or the database type. I am using Docker Compose, so this name comes from my docker-compose.yml file.

How do I connect the Postgres database running on the local machine to the docker container

I have a Flask application running on the container and Postgres database on the local machine and Now, I want to connect the Postgres DB (listening on 5432) to the docker container.
Can any one suggest the best way to do it ? (I am new to docker containers)
Thanks in advance.
You'll likely want to Dockerize your Postgres database in its own container and use a persistent volume to store your data locally.
Tutorial on how to Dockerize your Postgres database: https://docs.docker.com/engine/examples/postgresql_service/
Documentation on Docker volumes: https://docs.docker.com/engine/tutorials/dockervolumes/
Postgres image on Docker Hub: https://hub.docker.com/_/postgres/
You can use the IP address of your local machine to connect to the postgres from your Docker container. localhost will not be resolvable in certain machines.
You may have some interest in this post. From inside of a Docker container, how do I connect to the localhost of the machine?