I am attempting to write a containerized Node application that intakes Microsoft Access databases and accesses the data within. I want to put the application in a docker container and wish to use npm odbc to interact with Access. I don't have much experience creating containers so much of this has been a learning process.
I am struggling to get odbc installed and configured for Access. Per the documentation that I linked, there are three requirements for odbc.
- Install unixODBC and unixODBC-devel
- Install ODBC drivers for target database
- Define odbc.ini and odbcinst.ini
I am struggling to get any amount of odbc functionality working, so I assume the issue is that I'm not configuring the environment correctly. Here is my base Dockerfile where I define the container environment. Running the AccessDatabaseEngine.exe file returns a Not Found error, even though I'm pretty sure that the file should exist there. For now, I have commented out the line. The application code runs from a different set of Dockerfiles that build off this one.
# Use Ubuntu OS as base image
FROM ubuntu:latest
# Set env vars
ENV NPM_CONFIG_LOGLEVEL info
# odbc requirement #1
# Install unixODBC, unixODBC-devel, and curl
RUN apt-get update
RUN apt-get -y install unixodbc
RUN apt-get -y install unixodbc-dev
RUN apt-get -y install curl
# Download & install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_12.x | bash
RUN apt-get -y install nodejs
# odbc requirement #2
# Install ODBC drivers for Access database
RUN curl -LJO https://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe
RUN cp AccessDatabaseEngine.exe /bin/
RUN chmod +x /bin/AccessDatabaseEngine.exe
# RUN ['/bin/AccessDatabaseEngine.exe'] # Error: #14 0.249 /bin/sh: 1 [/bin/AccessDatabaseEngine.exe]: not found
# Run node
CMD [ "node" ]
In my application, I attempt to use odbc like this. The connection string for odbc requirement #3 was found here:
// Test function to test out npm odbc
exports.export = async (file) => {
// odbc requirement #3
// Make Access connection
const conn = await odbc.connect(`Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=${file.path}`);
// Execute test query
const res = await conn.query('SELECT 1');
console.log(JSON.stringify(res));
}
I feel pretty good about my implementation of odbc requirements #1 and #3, but I am struggling with #2 (Install ODBC drivers for target database). Not only am I struggling to run the AccessDatabaseEngine.exe, but I'm also not 100% sure that it's even the correct file to be trying to install. I ran into this and that seems like it might the odbc driver that I need. However, I tried dockerizing the code they gave and ran into more issues.
Again, I want to create a containerized Node application that uses the ODBC npm library to access the data within a Microsoft Access database. Does anybody have any experience doing this? Any help would be appreciated. Thanks ahead of time.
As it was said in the comments. I'm grasping at the wrong straws here. I cannot download Access Drivers onto my Linux machine. Per the driver system requirements here, I must use a Windows OS.