Home > Software engineering >  What Docker image do I choose that support python and install zbar shared library?
What Docker image do I choose that support python and install zbar shared library?

Time:10-06

I am trying to deploy my python app in a docker container. The application uses pyzbar package for QR decoding.

On a Mac, I use brew install zbar to install the shared libraries and in my requirements file, I have

pypng==0.20220715.0
pyzbar==0.1.9
PyQRCode==1.2.1

I have the following Dockerfile:

FROM python:3.7-slim-buster

RUN apt install python-zbar

the output of the last file is:

ERROR [2/8] RUN apt install python-zbar                                                                                                                                                            0.2s
------
 > [2/8] RUN apt install python-zbar:
#5 0.186 
#5 0.186 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#5 0.186 
#5 0.188 Reading package lists...
#5 0.194 Building dependency tree...E: Unable to locate package python-zbar
#5 0.195 
#5 0.195 Reading state information...
------
executor failed running [/bin/sh -c apt install python-zbar]: exit code: 100

Does anyone know a Docker Image that will support both?

CodePudding user response:

According to the zbar docs for Linux you need to install libzbar0 first, and then do a pip install pyzbar. You can have to following Docker image which does this:

FROM python:3.7-slim-buster

RUN apt-get update && apt-get install libzbar0 -y && pip install pyzbar

A little bit of explanation for exit code: 100 error:

This error usually happens when the command, which you are running, is waiting for user input. For apt-get install you can pass the -y flag to avoid having apt to prompt for an user input.

  • Related