Docker-Python脚本输入错误 [英] Docker-Python script input error

查看:128
本文介绍了Docker-Python脚本输入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手,我有一个名为ApiClient.py的脚本。
ApiClient.py脚本要求用户输入一些数据,例如用户的电子邮件,密码,输入文件(脚本将在其中获得一些输入信息)和输出文件(将在其中输出结果)。已经使用了这个Dockerfile:

I am new to Docker.I have a script named ApiClient.py. The ApiClient.py script asks the user to input some data such as user's email,password,the input file(where the script will get some input information) and the output file(where the results will be output).I have used this Dockerfile:

FROM python:3
WORKDIR /Users/username/Desktop/Dockerfiles
ADD . /Users/username/Desktop/Dockerfiles
RUN pip install --trusted-host pypi.python.org -r requirements.txt
EXPOSE 80
ENV NAME var_name
CMD ["python", "ApiClient.py"]

第一期:我使用此WORKDIR和ADD是因为

1st Issue: I have used this WORKDIR and ADD because thats where the input and output files exist.Is it wrong to declare these directories?

2n问题:脚本要求用户输入一些信息,例如电子邮件和密码但是,当我运行时:

2n Issue: The script asks for the user to input some info such as the email and password.However when i run:

docker run -p 4000:80 newapp

我收到以下错误:
用户名=(请输入您的用户名)

I get the following error: username = ("Please enter your username")

EOFError:读取行时的EOF

EOFError:EOF when reading a line

为什么会出现此错误?

推荐答案

使用 docker run -i -t< your-options>

所以在这里, -i代表交互模式,-t将为我们分配一个伪终端。

So here, -i stands for interactive mode and -t will allocate a pseudo terminal for us.

在您的方案中,

docker run -p 4000:80 -it newapp

希望有帮助!

这篇关于Docker-Python脚本输入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆