【问题标题】:docker build failed at 'Downloading mariadb'docker build 在“下载 mariadb”时失败
【发布时间】:2021-02-07 18:59:03
【问题描述】:

执行 'docker build -t $name .'以下问题失败。它显示'mariadb_config not found',但我已经在这个 suse15 linux 服务器上安装了 mariadb。

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

以及相关的Dockerfile内容如下。

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"]

【问题讨论】:

    标签: docker mariadb suse zypper


    【解决方案1】:

    在运行 pip3 install 之前,您需要在 Dockerfile 中安装 MariaDB Connector/C。将它安装在主机上并没有帮助。

    【讨论】:

      【解决方案2】:

      正如@Jonathan Jacobson 所写,在继续使用pip install 之前,您需要在Docker 映像中安装MariaDB 连接器。

      由于python:3.6.5 是基于debian 拉伸的,因此提供的连接器是2.3.2,mariadb 模块不支持(如prerequisites 中所述)。要解决此问题,您可能需要切换到不同的图像(例如 3.6-buster)。

      这是一个有效的测试:

      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"]
      

      【讨论】:

      • 谢谢。但是我的 linux 服务器是 suse15,所以在 Dockerfile 中添加了 'RUN zypper -n update && RUN zypper install libmariadb-dev'。然后点击以下问题。步骤 5/9 : RUN zypper -n update && RUN zypper install libmariadb-dev ---> Running in afdf5d71f900 /bin/sh: 1: zypper: not found 命令 '/bin/sh -c zypper -n update && RUN zypper install libmariadb-dev' 返回一个非零代码:127
      • 您的系统和 docker 镜像可能使用不同的发行版。例如当我测试它时,我在拱门上。
      • 对不起,我听不懂你的 cmets。你知道如何解决这个问题吗?
      • 当然。复制并粘贴我写的内容而不做任何更改并运行构建。
      • 太棒了!它现在可以工作,但在 docker run 时失败了。我将创建另一个问题,希望您能帮助指出错误。谢谢!
      【解决方案3】:

      使用以下命令安装 MariaDB Connector/C,这是一个依赖项。

      sudo apt-get install libmariadb3 libmariadb-dev

      RUN pip3 install -r requirements.txt

      【讨论】:

        猜你喜欢
        • 2021-03-06
        • 2020-09-14
        • 2022-11-30
        • 1970-01-01
        • 2023-01-11
        • 2021-05-14
        • 2017-05-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多