pyodbc not working in web-service container, Azure Model Management - docker

I am trying to create a web-service via Azure Model Management and am struggling.
I've followed the instructions and have managed to operationalize locally in a Docker container. My 'score.py' file includes a query to a SQL database using pyodbc. This functions perfectly when I test this on my local environment using the ML Workbench, however once this has been deployed in a Docker container I come across this error:
'Response Content': b'(\'01000\', "[01000] [unixODBC][Driver Manager]Can\'t open lib \'ODBC Driver 13 for SQL Server\' : file not found (0) (SQLDriverConnect)")'
I have included pyodbc in my conda_dependencies.yml.
Has anyone got any suggestions? Is there any further dependencies that I need to include?
Azure seem to have recently added the ability to customize container images using what they call a 'Docker Steps file'. I have practically no experience in Docker, but after reading this question i tried including a 'Docker Steps file' containing this:
ADD odbcinst.ini /etc/odbcinst.ini
RUN apt-get update
RUN apt-get install -y tdsodbc unixodbc-dev
RUN apt install unixodbc-bin -y
RUN apt-get clean -y
However i understand 'ADD' commands are not possible in this type of file, so this seems to have made no difference.
Hopefully this this all makes sense! Any advice would be very much appreciated! I hope I'm not the only one stumbling my way through Azure ML!
EDIT:
I'm still stuck, but making progress...
I accessed the root of the container using:
docker exec -ti -u root container_name bash
From here I ran 'odbcinst -j`, resulting in:
unixODBC 2.3.6
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
I couldn't seem to actually locate odbc.ini so i followed these instructions for installing 'ODBC Driver 13' for Ubuntu 16.04. Now when I run the service i get a different error:
{'Error': MlCliError({'Error': 'Error occurred while attempting to score service myapp.', 'Response Code': 502, 'Response Content': b'<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor="white">\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx/1.10.3 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n', 'Response Headers': {'Content-Length': '182', 'Content-Type': 'text/html', 'Date': 'Wed, 18 Apr 2018 14:06:30 GMT', 'Server': 'nginx/1.10.3 (Ubuntu)', 'Connection': 'keep-alive'}},), 'Azure-cli-ml Version': '0.1.0b2'}
I have also tried altering my score.py file to return: pyodbc.drivers() this results in a blank '[]'

Related

podman error: Error: error creating build container: initializing source

I have a strange problem with podman. I have a large Dockerfile of an open source project called spilo that I was always able to build. Today for some strange reason the same code doesn't work anymore. It's true that I haven't used podman for a month but today I got a strange problem. To simplify the error I created a simple Dockerfile just to show you the problem:
ARG BASE_IMAGE=ubuntu:18.04
ARG PGVERSION=14
ARG COMPRESS=false
FROM $BASE_IMAGE as builder-false
RUN apt-get update; apt-get install -y pgbackrest
FROM scratch as builder-true
COPY --from=builder-false / /
FROM builder-${COMPRESS}
Now if I run:
podman build . -t prova:latest
I got the following error:
[3/3] STEP 1/1: FROM builder-false
Resolving "builder-false" using unqualified-search registries (/etc/containers/registries.conf.d/999-podman-machine.conf)
Trying to pull docker.io/library/builder-false:latest...
Error: error creating build container: initializing source docker://builder-false:latest: reading manifest latest in docker.io/library/builder-false: errors:
denied: requested access to the resource is denied
unauthorized: authentication required
It seems it try to search the builder-false image from docker.io repository instead try to build it from the row above. The steps to create the builder-false are not executed.
Can anyone help me to address this issue?
The original spilo project Dockerfile always worked. I reinstalled the podman VM but no luck. I also restarted the Mac, no luck.
I think there is a bug somewhere in dependencies of pgbackrest. I got this on my podman (centos 8) executing RUN apt-get install -y pgbackrest:
chfn: PAM: System error
adduser: `/usr/bin/chfn -f PostgreSQL administrator postgres' returned error code 1. Exiting.
dpkg: error processing package postgresql-common (--configure):
installed postgresql-common package post-installation script subprocess returned error exit status 1
With docker works fine.

Using Node odbc with Microsoft Access

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.

Composer Docker image won't run at all

I'm attempting to learn how to create a Laravel Docker image by following a tutorial on DigitalOcean using WSL. Following the instructions on the Docker Hub page, however, yields an error:
❯ docker run --rm --interactive --tty -v $(pwd):/app composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 94 installs, 0 updates, 0 removals
- Installing voku/portable-ascii (1.4.10): Failed to download voku/portable-ascii from dist: Could not delete /app/vendor/voku/portable-ascii/src/voku/helper:
Now trying to download from source
- Installing voku/portable-ascii (1.4.10):
[RuntimeException]
Could not delete /app/vendor/voku/portable-ascii/src/voku/helper:
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
How can I diagnose what I'm doing wrong?
It turns out that the underlying problem had nothing to do with Docker at all. In fact, Composer was trying to tell me what the problem was all along, but I dismissed it as just a symptom of a deeper issue:
[RuntimeException]
Could not delete /app/vendor/voku/portable-ascii/src/voku/helper:
This message was the crux of it all. I noticed that the directory mentioned, [...]/helper, was empty, so I tried to remove it by hand with rmdir. Instead, I got a No such file or directory error message. I attempted many other was to kill this directory, the entire project directory with rm -rf ~/laravel-app from the home folder, etc. Nothing worked.
Some digging around on the internet suggested that it could be an NTFS corruption if I was running into this issue on Windows. Since I am, indeed, attempting this on WSL (Windows Subsystem for Linux), I gave their suggested fix a try: running chkdsk /F in CMD/PowerShell. A reboot was necessary to complete this task, but after getting everything back up and trying those first few tutorial steps again, I was able to get composer to install the Laravel dependencies without a hitch.
Bottom line: If you run into this sort of issue on WSL, please try running chkdsk /F and reboot. You might just have a similar file system corruption.
We have two possibilities for this error:
1 - You did not execute the command inside the directory :
cd ~/laravel-app
2 - I'm sure there is an internal proxy that is blocking the download of packages.

Ubuntu, shopsys install via composer, docker, still crashing

I wanna install shopsys via composer and docker, as is recommended.
https://github.com/shopsys/shopsys/blob/master/docs/installation/installation-using-docker-linux.md
I installed git, php-fpm (configured), postgres (configured), composer, docker, docker-compose.
sudo apt install git
sudo apt install php7.2-fpm
sudo apt install postgresql
sudo apt install composer
sudo apt install docker-ce
sudo apt install docker-compose
Everything ok.
I added my user to docker group.
sudo usermod -a -G docker $(whoami)
Ok.
Next I made folder /var/www/html/shopsys, created project shopsys via composer.
composer create-project shopsys/project-base --no-install --keep-vcs
cd project-base/
Then I run this in /var/www/html/shopsys/project-base.
./scripts/install.sh
Everything seems to be ok, until this.
[RuntimeException]
/var/www/html/vendor does not exist and could not be created.
I set rights to 777 for folder /var/www/html, and run it again, but same problem.
The I run this.
sudo composer install
It shows me this error.
....Exception\InvalidConfigurationException]
Invalid configuration for path "monolog.handlers.main": You can only use ex
cluded_http_codes/excluded_404s with a FingersCrossedHandler definition
In ScriptHandler.php line 294:
An error occurred when executing the "'shopsys:domains-urls:configure'" command:
In BaseNode.php line 319:
...\Exception\InvalidConfigurationException]
Invalid configuration for path "monolog.handlers.main": You can only use ex
cluded_http_codes/excluded_404s with a FingersCrossedHandler definition
...
etc., error is quite ugly.
Last error when i run script install.sh.
file_put_contents(/var/www/html/vendor/composer/installed.json): failed to open stream: Permission denied
But this folder does not exist.
ls: cannot access '/var/www/html/vendor/': No such file or directory
Just question, where could be the problem?
Is possible to download sources from some link, extract it, configure and display in web browser with easy way, for example as wordpress?
Thanks.
To solve problem with vendor:
It seems that your UID and GID is different than default 1000, that is set in docker-compose.yml for Linux by default.
To solve your issue you can continue by step 3 in https://github.com/shopsys/shopsys/blob/master/docs/installation/installation-using-docker-linux.md#3-set-the-uid-and-gid-to-allow-file-access-in-mounted-volumes
You found issue with installation script, I have created issue on GitHub.
To solve problem with Invalid configuration for path "monolog.handlers.main":
Currently there is problem with new minor version (3.4.0) of symfony/monolog-bundle that created BC break. There is already created issue about this problem and there is already merged fix in Shopsys master.
To solve problem in your project you have to add
"symfony/monolog-bundle": ">=3.4.0", in conflict section in your composer.json file and then run composer install again.
We are trying to answer questions on stackoverflow as soon as possible, but we also have Slack where is many users and you might get your question answered much faster.

Suse Linux docker file

I have a suse linux 12 ec2 instance. I have activated a image sles11sp3-docker-image using sledocker. In the Dockerfile when I try to install ibm java 1.6 using
RUN zypper in java-1_6_0-ibm, I get following error .
Refreshing service 'container-suseconnect'.
Problem retrieving the repository index file for service 'container-suseconnect':
[|]
Skipping service 'container-suseconnect' because of the above error.
Warning: No repositories defined. Operating only with the installed resolvables. Nothing can be installed.
Loading repository data...
Reading installed packages...
'java-1_6_0-ibm' not found in package names. Trying capabilities.
Resolving package dependencies...
No provider of 'java-1_6_0-ibm' found.
Nothing to do.
The command '/bin/sh -c zypper in java-1_6_0-ibm' returned a non-zero code: 104
Please help
According to the docs (https://www.suse.com/documentation/sles-12/singlehtml/dockerquick/dockerquick.html), running zypper ref -s only gets you repo URLs with 12 hour tokens. Moreover, this command only appears to work while running in Docker on a SLES12 host.
Once I push the image to a repo and run it on another host, zypper ref -s no longer works (same error as yours). I'm basically stuck pre-installing all the base stuff before I publish the image.

Resources