简体   繁体   English

Docker 运行脚本但服务器不工作

[英]Docker running script but server doesn't work

I am doing an encryption service that everytime a user goes on the server it changes the key, the problem is that when i run the python file alone in works like this when it works我正在做一个加密服务,每次用户进入服务器时它都会更改密钥,问题是当我单独运行 python 文件时,它会像这样工作

but when I am dockerizing it by the below code但是当我通过下面的代码对它进行码头化时

FROM python:3

RUN mkdir -p "C:\Users\joel\Desktop\mcast-freshers-week-devops-main\mcast-freshers-week-devops-main\encryption-service"

COPY requirements.txt ./
RUN pip install -r requirements.txt


COPY . .
CMD [ "python", "app.py" ]

The build and run are succesful even the container it is being created, even the output from the python code is shown enter image description here即使是正在创建的容器,构建和运行也是成功的,甚至显示了 python 代码中的 output在此处输入图像描述

but when i go to the server it shows this enter image description here但是当我向服务器输入 go 时,它会在此处显示此输入图片描述

I tried everything but I don't know what to do.我尝试了一切,但我不知道该怎么做。

I treid changing the code many times but i still cant solve it, I narrowed it down because i tried another python application and it worked.我多次更改代码但我仍然无法解决它,我缩小了它的范围,因为我尝试了另一个 python 应用程序并且它有效。

When you run your command with docker run, you can always expose the internal port on the docker container to match your local host.network port, use this command instead for running your docker container当您使用 docker run 运行您的命令时,您始终可以公开 docker 容器上的内部端口以匹配您的本地 host.network 端口,使用此命令代替运行您的 docker 容器

docker run -it --rm -p 8080:8080 --name my-running-app my-python-app

You can then access your server by visiting localhost:8080然后,您可以通过访问 localhost:8080 来访问您的服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM