gpt4 book ai didi

docker - Windows兼容性:权限?

转载 作者:行者123 更新时间:2023-12-02 19:25:29 26 4
gpt4 key购买 nike

操作系统Windows 10,
我正在使用Docker Engine版本18.09.2,API版本是1.39

解释运行CAT的步骤的网站是:https://libraries.io/pypi/medcat

我正在本地构建medcat镜像。在构建过程结束之前,输出看起来不错:

    Step 10/11 : ENTRYPOINT ["python"]
---> Using cache
---> 66b414e2093d
Step 11/11 : CMD ["api.py"]
---> Using cache
---> db2acf6c4649
Successfully built db2acf6c4649
Successfully tagged cat:latest
SECURITY WARNING: You are building a Docker image from Windows against
a non-Windows Docker host. All files and directories added to build
context will have '-rwxr-xr-x' permissions. It is recommended to
double check and reset permissions for sensitive files and
directories.

当我尝试启动刚刚构建的容器时,我得到:
    IT IS UMLS
* Serving Flask app "api" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a
production deployment.
Use a production WSGI server instead.
* Debug mode: on
Traceback (most recent call last):
File "api.py", line 66, in <module>
app.run(debug=True, host='0.0.0.0', port=5000)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line
944, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python3.7/site-packages/werkzeug/serving.py",
line 1007, in run_simple
run_with_reloader(inner, extra_files, reloader_interval,
reloader_type)
File "/usr/local/lib/python3.7/site-packages/werkzeug/_reloader.py",
line 332, in run_with_reloader
sys.exit(reloader.restart_with_reloader())
File "/usr/local/lib/python3.7/site-packages/werkzeug/_reloader.py",
line 176, in restart_with_reloader
exit_code = subprocess.call(args, env=new_environ,
close_fds=False)
File "/usr/local/lib/python3.7/subprocess.py", line 323, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.7/subprocess.py", line 1522, in
_execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/cat/api/api.py'

是否有人在Windows上构建过经验?安全警告与此有关吗?

更新:
我在本文中收到的答案中添加了linux可执行文件的权限。然后,我使用以下命令 docker build --network=host -t cat -f Dockerfile.MedMen .在本地构建了镜像,构建过程的最后给出了相同的 Security Warning
然后我检查了 docker run --env-file=./envs/env_medann ubuntu:18.04 env,它给了我:
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=3d5fd66fadbe
TYPE=UMLS
DEBUG=False
CNTX_SPAN=6
CNTX_SPAN_SHORT=2
MIN_CUI_COUNT=100
MIN_CUI_COUNT_STRICT=1
MIN_ACC=0.01
MIN_CONCEPT_LENGTH=1
NEG_PROB=0.2
LBL_STYLE=def
SPACY_MODEL=en_core_sci_md
UMLS_MODEL=/cat/models/med_ann_norm.dat
VOCAB_MODEL=/cat/models/med_ann_norm_dict.dat
MKL_NUM_THREAD=1
NUMEXPR_NUM_THREADS=1
OMP_NUM_THREADS=1
HOME=/root

最佳答案

这是因为Windows和linux存在CR-LFLF差异的问题,同时,需要为linux可执行文件添加权限。

对于您的情况,当您获得源代码时,我认为您已在Windows上安装了git。然后,您可以打开Git Bash,更改源代码目录的路径,然后在其中执行下一步:

找 。型f | xargs dos2unix
chmod -R 777 *

最后,重建它。

更新:

我完全尝试了您的代码,看来问题出在cat/api/api.py,但未找到#!。因此,在您的源代码中,编辑cat/api/api.py,然后在源代码的开头添加下一个:

#!/usr/bin/env python

然后,使用Dockerfile重建并再次运行它,您可以从浏览器中看到效果:

enter image description here

关于docker - Windows兼容性:权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56663926/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com