Map host port to a docker port

In my host CentOS 7 a posgres database is running on port 5432. I want to connect this database from my docker container.
I tried --add-host for host database mapping but it still gives me an error:
Kindly check the error log below:

{ error: no pg_hba.conf entry for host “”, user “postgres”, database “ankit”, SSL off
at Connection.parseE (/usr/app/node_modules/pg/lib/connection.js:604:11)
at Connection.parseMessage (/usr/app/node_modules/pg/lib/connection.js:401:19)
at Socket. (/usr/app/node_modules/pg/lib/connection.js:121:22)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
name: ‘error’,
length: 161,
severity: ‘FATAL’,
code: ‘28000’,
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: ‘auth.c’,
line: ‘489’,
routine: ‘ClientAuthentication’ }

Can you explain better? do you have a postgres instance (not docker) and do you have to connect to this database from container? You have to call the db on IP_HOST: 5432

Yup. I got the solution for the same. Issue was with the docker network. By default it was taking bridge network, I changed it to host which solved the issue.

You need to define the port in your command
docker exec -it -p container_id