Help with setting up SQL ODBC database connection in IRIS container
I'm running the image "containers.intersystems.com/intersystems/irishealth-community:2025.1" as a container on my local Docker desktop.
Now I want to set up an ODBC SQL connection, but I don't know how to do it.
I have tried various ways without success. Like building my own image (see "Dockerfile" description below).
I have also added ODBCINI variable in my docker-compse (see "Docker-compose.yml" description below).
Anyone done this before?
I'd really appreciate some help.
Thanks.
Dockerfile
FROM containers.intersystems.com/intersystems/irishealth-community:2025.1
USER root
RUN apt-get update && \
apt-get install -y unixodbc odbc-postgresql && \
apt-get clean && rm -rf /var/lib/apt/lists/*
COPY odbc.ini /etc/odbc.ini
COPY odbcinst.ini /etc/odbcinst.ini
USER irisowner
Docker-compose.yml
services:
iris:
build: .
container_name: iris
ports:
- "52773:52773"
- "1972:1972"
environment:
- ODBCINI=/etc/odbc.ini
volumes:
- ./iris-init:/irisdev/app
- iris_data:/ISC/durable
- /c/temp/IRIS-mnt/mgr:/opt/hc/mgr # For storing namespace data
networks:
- irisnet # Setting this to be in the same docker network as the postgres database I want to connect to.
volumes:
iris_data:
networks:
irisnet:
external: true
Comments
To set up an ODBC connection from your IRIS container to an external database, you need two layers configured:
- an OS-level ODBC DSN inside the container, and
- an InterSystems IRIS SQL Gateway connection that uses that DSN. [1]
For the IRIS side, the SQL Gateway ODBC connection must use a DSN; it does not support connections without one. [1]
A practical setup based on the retrieved material is:
- install unixODBC and the target database’s ODBC driver in the container,
- create
odbcinst.iniandodbc.ini, - set
ODBCINIto the full path of the ODBC initialization file, - then create the SQL Gateway connection in the Management Portal using that DSN. [2][1]
Your docker-compose.yml approach of setting ODBCINI=/etc/odbc.ini is consistent with the documented Linux requirement to set ODBCINI to the full path, including filename, of the ODBC initialization file. [3]
For Linux, the ODBC initialization file is typically odbc.ini, and the documented pattern looks like this: [3]
[ODBC Data Sources]
MyDSN = MyDSN
[MyDSN]
Driver = /path/to/driver.so
Host = <host>
Port = <port>
Namespace = <namespace>
UID = <username>
Password = <password>
Protocol = TCP
Query Timeout = 1
Static Cursors = 0
Trace = off
TraceFile = logfile.log
If you are configuring a generic external database DSN, the exact DSN fields depend on that database’s ODBC driver, but IRIS expects that DSN to already exist before you define the SQL Gateway connection. [1]
In the Management Portal, define the IRIS SQL Gateway connection like this:
- Go to System Administration > Configuration > Connectivity > SQL Gateway Connections.
- Click Create New Connection.
- Set Type of connection = ODBC.
- Enter a Connection Name.
- In Select an existing DSN, choose the DSN you created in
odbc.ini. - Enter User and Password if needed.
- Optionally click Test Connection.
- Click Save. [1]
A key troubleshooting point from the Linux container example is that ODBC installation steps may create blank /etc/odbc.ini and /etc/odbcinst.ini files, which can break things. In that example, they explicitly removed those blank files and recreated links to the real config files. [2]
Note: The reason for the above is, step 3 & 4 would normally create 2 blank (hence invalid) ODBC files in \etc\ directory. Unlike Windows installation, these blanks ini files cause troubles, hence we need to delete them first, then simply re-create a link to the real ini files provided in a mapped Docker volume: /tf/odbcinst.ini, and /tf/odbc.ini [2]
That same example says these files must exist and be valid for Linux ODBC to work:
odbcinst.iniodbc.ini- the actual driver shared library file referenced by
odbcinst.iniorodbc.ini[2]
It also shows a useful verification step:
odbcinst -j
This lets you confirm which files unixODBC is actually using for drivers and system data sources. In the example output, it reports the paths for odbcinst.ini and odbc.ini. [2]
So the main things to check in your container are:
ODBCINIpoints to the realodbc.inifile. [3]/etc/odbc.iniand/etc/odbcinst.iniare not blank or invalid placeholder files. [2]- The driver entry in
odbcinst.inipoints to a real installed shared library. [2] - The DSN exists in
odbc.ini. [1] - After that, you still need to create the SQL Gateway connection in IRIS Management Portal; having only the OS files is not enough. [1]
[!NOTE]
For OS-specific instruc [1]
The retrieved material does not include a complete PostgreSQL-specific odbc.ini/odbcinst.ini example for IRIS SQL Gateway, so I can only confirm the required structure and process, not the exact PostgreSQL DSN syntax for your driver. [2][1]
If you want, paste your current odbc.ini and odbcinst.ini contents, and I can help you compare them against the required DSN/SQL Gateway structure shown here. [2][1]
Sources: