如何解决docker build在“下载mariadb”时失败
执行'docker build -t $ name'。在以下问题上失败。它显示“找不到mariadb_config”,但我已经在此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"]
解决方法
在运行pip3 install
之前,您需要在Dockerfile中安装MariaDB Connector / C。将其安装在主机上并没有帮助。
就像@Jonathan Jacobson所写的那样,您需要在Docker映像中安装MariaDB连接器,然后再继续进行pip install
。
由于python:3.6.5
基于debian Stretch,因此那里提供的连接器是2.3.2,mariadb
模块不支持(如prerequisites中所述)。要解决此问题,您可能需要切换到其他图片(例如3.6克星)。
这是一个工作测试:
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"]
,
使用以下命令安装MariaDB Connector / C,这是一个依赖项。
sudo apt-get install libmariadb3 libmariadb-dev
RUN pip3 install -r requirements.txt
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。