我真的需要docker帮助。
我的docker文件如下:
FROM python:3-alpine
LABEL author="alaa"
LABEL description="Dockerfile for Python script which generates emails"
RUN pip install tqdm
COPY email_generator.py /app/
CMD python3 /app/email_generator.py
我的pthon代码如下:
import json # to read json files
import os # to access operation for get and changing directory
def writeTextFile(text,index):
f = open(ziel + '/email_%s.txt' % index,'w+')
f.write(text)
f.close()
def writeHashFile(text):
f = open(ziel + '/00_Hash.json','w+')
f.write(str(text))
f.close()
def readJsonCordinate(fileName):
"""Read the json data."""
with open(fileName,'r',encoding='utf-8') as f: # Opening the file
data = json.load(f) # Read the json file
return data
以此类推...
我的问题是,如果要在构建映像后从主机系统获取文件,则会出现此错误。但是,如果我在macOS的pycharm上天真地运行代码,它将运行完美
Traceback (most recent call last):
File "/app/email_generator.py",line 112,in <module>
betreff = readJsonCordinate(quelle + '/Betreff.json')
File "/app/email_generator.py",line 22,in readJsonCordinate
with open(fileName,encoding='utf-8') as f: # Opening the file
FileNotFoundError: [Errno 2] No such file or directory: '/Users/soso/desktop/email_generator/Worterbuecher/Betreff.json'