简体   繁体   English

如何使用我的项目的 .pyc(pycache)文件构建 docker

[英]How can I build docker with .pyc (pycache) files of my project

I had run this:我运行了这个:

docker build -t image_name .

and docker built successfully but when I run it I get this error:并且 docker 构建成功,但是当我运行它时,出现此错误:

bad magic number

there is not a way to make docker with pycache files?没有办法用 pycache 文件制作 docker 吗?

You can convert your .py files to .pyc like so:您可以像这样将 .py 文件转换为 .pyc:

python -m compileall .

you should compile with the same version of python that you run in your docker container您应该使用在 docker 容器中运行的相同版本的 python 进行编译

By the error, I assume you use different versions for both tasks.根据错误,我假设您对这两个任务使用不同的版本。

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

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