docker build failed at 'Downloading mariadb'

2.3k views Asked by At

Executing 'docker build -t $name .' failed at following issue. It shows 'mariadb_config not found', but i already installed mariadb on this suse15 linux server.

Collecting mariadb==1.0.4
  Downloading mariadb-1.0.4.tar.gz (66 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lxx0giq5/mariadb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lxx0giq5/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-hicsuruq
         cwd: /tmp/pip-install-lxx0giq5/mariadb/
    Complete output (17 lines):
    /bin/sh: 1: mariadb_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-lxx0giq5/mariadb/setup.py", line 26, in <module>
        cfg = get_config(options)
      File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 59, in get_config
        cc_version = mariadb_config(config_prg, "cc_version")
      File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 29, in mariadb_config
        "mariadb_config not found.\n\nPlease make sure, that MariaDB Connector/C is installed on your system.\n"
    OSError: mariadb_config not found.

    Please make sure, that MariaDB Connector/C is installed on your system.
    Either set the environment variable MARIADB_CONFIG or edit the configuration
    file 'site.cfg' and set the 'mariadb_config option, which should point
    to the mariadb_config utility.
    The MariaDB Download website at <https://downloads.mariadb.com/Connectors/c/>
    provides latest stable releease of Connector/C.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1

And related Dockerfile content is as follows.

FROM python:3.6.5

WORKDIR /slic-scripts

COPY requirements.txt .

RUN pip install --upgrade pip

RUN pip3 install -r requirements.txt

COPY . .

CMD ["python3", "/slic-scripts/run_cmd.sh"]
3

There are 3 answers

6
Stefano On BEST ANSWER

As @Jonathan Jacobson wrote, you need to have the MariaDB Connector installed in your Docker image before proceeding with pip install.

Since python:3.6.5 is based on debian stretch, the connector offered there is 2.3.2 which is not supported by the mariadb module (as stated in the prerequisites). To fix this, you might want to switch to a different image (e.g. 3.6-buster).

Here's a working test:

FROM python:3.6-buster

RUN apt-get update \
    && apt-get -yy install libmariadb-dev

WORKDIR /slic-scripts
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY . .

CMD ["python3", "/slic-scripts/run_cmd.sh"]
0
Jonathan Jacobson On

You need to install MariaDB Connector/C inside the Dockerfile, before running pip3 install. It doesn't help that you installed it on your host.

0
Ashok On

Install MariaDB Connector/C using the below command, which is a dependency.

sudo apt-get install libmariadb3 libmariadb-dev

RUN pip3 install -r requirements.txt