Flask服务无法在Docker容器中运行

时间:2018-09-06 00:42:21

标签: python docker

我在这里拥有能够创建映像的Dockerfile。问题在于,即使文件存在,程序执行也无法读取子目录路径中的文件。

FROM ubuntu:16.04
MAINTAINER Vivek Kaul "vkaul11@gmail.com"
#Install Ubuntu pkgs
COPY apt.conf /etc/apt/apt.conf
COPY . /product_info
WORKDIR /product_info
RUN apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates \
        vim \
        git \
        python \
        python-pip \
        curl \
        wget \
        lsof \
        libmysqlclient-dev \
        python-dev \
        python-mysqldb \
        build-essential \
        && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

#PYTHON requirements

ENV HTTPS_PROXY "https://gec-proxy-svr.homeoffice.wal-mart.com:8080/"

RUN python --version
RUN pip install pip --upgrade
RUN pip install --upgrade setuptools
RUN pip install -r requirements.txt


EXPOSE 9000


RUN ls -la /product_info/key_matching/data

ENTRYPOINT ["sh", "-c", "python key_matching/key_matching_endpoint.py"]

当我运行docker run -p 9000:9000 product_info时遇到错误

Traceback (most recent call last):
  File "key_matching/key_matching_endpoint.py", line 5, in <module>
    from key_matching import find_keys
  File "/product_info/key_matching/key_matching.py", line 11, in <module>
    from label_keys import key_to_label
  File "/product_info/key_matching/label_keys.py", line 67, in <module>
    with open('data/all_keys_sorted.txt', 'r') as f:
IOError: [Errno 2] No such file or directory: 'data/all_keys_sorted.txt'

我可以在docker之外运行所有内容,也可以运行

的输出
RUN ls -la /product_info/key_matching/data

显示工作目录中存在文件data / all_keys_sorted.txt。

-rw-r--r-- 1 root root 45713 Sep  5 12:32 all_keys_sorted.txt
drwxr-xr-x 2 root root  4096 Sep  5 12:36 thresholds

当我在docker外部运行所有内容时,我无法理解其原因

0 个答案:

没有答案