When you refer to localhost within a Docker container, you cannot access a service on the Docker host. To resolve the internal IP address used by the host, use host.docker.internal
.
For example, you run your PostgreSQL instance on localhost:5433/dbname
. The connection string would be jdbc:postgresql://host.docker.internal:5433/dbname
.
This data source payload will create a data source called my-ds
:
{
"data": {
"attributes": {
"name": "my-ds",
"url": "jdbc:postgresql://host.docker.internal:5433/dbname",
"schema": "<schema>",
"type": "POSTGRESQL",
"username": "<user>",
"password": "<password>",
"enableCaching": false
},
"id": "my-ds",
"type": "dataSource"
}
}
See API Reference for how to create a data source.