python - 如何概括用于 Docker 图像的 python?
问题描述
抱歉,如果这是一个不好的问题,我仍然是 Docker 的初学者,所以我寻求您的理解。
我正在尝试对应用程序进行 dockerize 处理。在应用程序中,有一个 json 配置文件,其中说明了 python 的文件路径。它用于不同的机器有不同的 python 路径。
例如,
{
"python_file_path":"/home/ubuntu/miniconda3/bin/python",
"other_config":"exampleconfig"
}
.
此配置文件最初位于我试图 dockerize 的项目文件夹中。
但是,在对应用程序进行 dockerizing 并尝试在另一台机器上运行我的图像后,出现以下错误:
FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/miniconda3/bin/python': '/home/ubuntu/miniconda3/bin/python'
因此,我想知道 Docker 是如何在构建映像时准确打包所需的 python 的?另外,如何更改 json 文件以使其在所有机器上通用?
这是我的码头文件。我的运行命令是docker run -p 4000:80 nlpengine
# Use an official Python runtime as a parent image
FROM python:3.7-slim
# Set the working directory to /app
WORKDIR /transfer_learning
# Copy the current directory contents into the container at /app
COPY . /transfer_learning
# Install any needed packages specified in requirements.txt
RUN apt-get update
RUN apt-get -y install gcc mono-mcs
RUN apt-get -y install unixodbc unixodbc-dev
RUN apt-get -y install --reinstall build-essential
RUN pip install --trusted-host pypi.python.org -r requirements.txt
RUN python -m spacy download en
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "nlp_engine_daemon.py"]
解决方案
推荐阅读
- c# - 为什么 Request.files arrayList 是空的?C#
- asp.net - 在我的长期运行过程中无法访问已处置的对象
- html - 定位绝对定位的旋转文本
- javascript - VueJS 翻译插件
- spring - spring-security-oauth2 不适用于 Java 10
- c++ - 为什么这个指向常量指针的指针分配是非法的?
- javascript - 流 - 如何键入由嵌套在其中的对象组成的对象
- lambda - 半自动 NightmareJS -> 能够在 Lambda 上查看/与 Electron 浏览器窗口交互
- matlab - Matlab滤波器与平滑数据
- ssis - SSIS 2017 - 包装部件 - “P”消失,不再可配置