python - 无法在 docker compose 中打开 .env/activate 但在 docker build 中工作
问题描述
以下是我的码头文件
FROM ubuntu:18.04
# Upgrade installed packages
RUN apt update
RUN apt upgrade -y
ENV TZ=Europe/London
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get install -y libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
WORKDIR /code
RUN apt-get -y install python3-pip
RUN apt-get -y install python3-venv
RUN apt -y install python3-setuptools libffi-dev python3-dev
RUN apt install -y curl
RUN apt install -y unzip
RUN apt-get install -y build-essential swig
WORKDIR /code
RUN python3 -m venv .env
RUN . .env/bin/activate && pip install --upgrade pip && curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | LC_ALL=C.UTF-8 xargs -n 1 -L 1 pip install
COPY requirements.txt requirements.txt
RUN . .env/bin/activate && pip install pyenchant && pip install -r requirements.txt
RUN apt install -y libgl1-mesa-glx
RUN apt-get install -y libglib2.0-0
RUN apt-get install -y libenchant1c2a
RUN mkdir embeddings
COPY . .
RUN curl -L http://nlp.stanford.edu/data/glove.6B.zip --output glove.zip
RUN unzip -o glove.zip -d embeddings/
RUN . .env/bin/activate && python nltk_install.py
CMD . .env/bin/activate && python main.py
它在使用构建时有效docker build .
Docker-撰写文件
version: "3.9" # optional since v1.27.0
services:
pythonscripts:
build: .
volumes:
- "/mnt/d/code/data1/:/code/data/"
但是当我尝试使用 docker-compose 时docker-compose up
。它给出以下错误:
Successfully built 06caf1786bfe
Successfully tagged openbotsdocumentsautomlpythonscripts_pythonscripts:latest
WARNING: Image for service pythonscripts was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating openbotsdocumentsautomlpythonscripts_pythonscripts_1 ... done
Attaching to openbotsdocumentsautomlpythonscripts_pythonscripts_1
pythonscripts_1 | /bin/sh: 1: .: Can't open .env/bin/activate
openbotsdocumentsautomlpythonscripts_pythonscripts_1 exited with code 2
解决方案
推荐阅读
- google-apps-script - OnSelectionChange 与 SpreadsheetApp.getUI().alert("Message") 不一致 - Google Apps 脚本
- dataframe - 如何将内联数据集(增量)的参数化链接服务的参数传递给数据流?
- bash - 如何在 CMake 生成的 Makefile 中编译所有目标的子集,这些目标以 bash for 循环中的给定前缀开头
- node.js - 创建与 MongoDB 日期一起使用的自定义 GraphQLDateTime 标量
- reactjs - 用不同的值在 Mongoose 中更新多个文档——Express Js
- vba - 如何在 VBA 的 Access 表中为日期时间字段分配值?
- edi - 交易集的 EDI 样本数据
- r - 使用 RedditExtractoR 的 get_reddit 函数时出错
- python - 在 Python 中转换图像,为每个像素指定目标坐标
- html - iOS Voice Over 无法读取 Aria-Label