我试图使用自定义的Dockerfile来构建LUIS容器,并将app文件(从Luis导出的应用程序)复制到容器中。由于这个原因,我真的不需要挂载点,因为.gz文件已经存在于容器中。这个是可能的吗?似乎总是需要安装点..。
我必须将文件复制到容器中,并在运行时将它们移动到input位置(使用init.sh脚本)。但是,即使在那时,容器似乎没有正确地加载应用程序。与只将文件放入主机文件夹并将其挂载到容器相比,它的行为与该场景不同。
更新:当我试图在内部(容器开始时)移动文件时,LUIS给出了如下输出:
Using '/input' for reading models and other read-only data.
Using '/output/luis/fbfb798892fd' for writing logs and other output data.
Logging to console.
Submitting metering to 'https://southcentralus.api.cognitive.microsoft.com/'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'http://+:80'. Binding to endpoints defined in UseKestrel() instead.
Hosting environment: Production
Content root path: /app
Now listening on: http://0.0.0.0:5000
Application started. Press Ctrl+C to shut down.
fail: Luis[0]
Failed while prefetching App: AppId: d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee - Slot: PRODUCTION Could not find file '/input/d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_PRODUCTION.gz'.
fail: Luis[0]
Failed while getting response for AppId: d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee - Slot: PRODUCTION. Error: Could not find file '/input/d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_PRODUCTION.gz'.
warn: Microsoft.CloudAI.Containers.Controllers.LuisControllerV3[0]
Response status code: 404
Exception: Could not find file '/input/d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_PRODUCTION.gz'. SubscriptionId='' RequestId='d7dfee25-05d9-4af6-804d-58558f55465e' Timestamp=''
^C
nuc@nuc-NUC8i7BEK:/tmp/input$ sudo docker exec -it luis bash
root@fbfb798892fd:/app# cd /input
root@fbfb798892fd:/input# ls
d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_production.gz
root@fbfb798892fd:/input# ls -l
total 8
-rwxrwxrwx 1 root root 4960 Dec 2 17:35 d6fa5fd3-c32a-44d5-bb7f-d563775cf6ee_production.gz
root@fbfb798892fd:/input# 请注意,即使我可以登录容器并浏览模型文件的位置并且它们是存在的,LUIS仍然无法加载/找到它们。
更新#2 -发布我的Dockerfile:
FROM mcr.microsoft.com/azure-cognitive-services/luis:latest
ENV Eula=accept
ENV Billing=https://southcentralus.api.cognitive.microsoft.com/
ENV ApiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ENV Logging:Console:LogLevel:Default=Debug
RUN mkdir /app/inputfiles/
RUN chmod 777 /app/inputfiles/
COPY *.gz /app/inputfiles/
WORKDIR /app
COPY init.sh .
RUN chmod 777 /app/init.sh
ENTRYPOINT /app/init.sh && dotnet Microsoft.CloudAI.Containers.Luis.dll发布于 2019-12-03 21:46:26
备选案文1
模型可以被COPY直接转化为/input/。
FROM mcr.microsoft.com/azure-cognitive-services/luis:latest
COPY *.gz /input/这将有效,但您的不需要在运行时挂载到/input,因为它会压缩COPY'd文件。只有当/input目录不存在时,才会记录“必须挂载文件夹”的消息。
> docker build . -t luis --no-cache
Sending build context to Docker daemon 40.43MB
Step 1/2 : FROM aicpppe.azurecr.io/microsoft/cognitive-services-luis
---> df4e32e45b1e
Step 2/2 : COPY ./*.gz /input/
---> c5f41a9d8522
Successfully built c5f41a9d8522
Successfully tagged luis:latest
> docker run --rm -it -p 5000:5000 luis eula=accept billing=*** apikey=***
...
Using '/input' for reading models and other read-only data.
...
Application started. Press Ctrl+C to shut down.选项2
可以将配置值Mounts:Input设置为配置输入位置。
如果您需要您的模型驻留在/app/inputfiles中,或者由于另一个原因需要在运行时挂载到/input,这可能很有用。
例如:
FROM aicpppe.azurecr.io/microsoft/cognitive-services-luis
ENV Mounts:Input=/app/inputfiles
COPY ./*.gz /app/inputfiles/这导致:
> docker build . -t luis --no-cache
Sending build context to Docker daemon 40.43MB
Step 1/3 : FROM aicpppe.azurecr.io/microsoft/cognitive-services-luis
---> df4e32e45b1e
Step 2/3 : ENV Mounts:Input=/app/inputfiles
---> Running in b6029a2b54d0
Removing intermediate container b6029a2b54d0
---> cb9a4e06463b
Step 3/3 : COPY ./*.gz /app/inputfiles/
---> 9ab1dfaa36e7
Successfully built 9ab1dfaa36e7
Successfully tagged luis:latest
> docker run --rm -it -p 5000:5000 luis eula=accept billing=*** apikey=***
...
Using '/app/inputfiles' for reading models and other read-only data.
...
Application started. Press Ctrl+C to shut down.发布于 2019-11-26 23:16:40
如果您的.gz文件已经在映像中,那么输入挂载是不必要的,但是输出挂载用于日志记录,您可能仍然希望它用于主动学习目的。
要构建所需的映像,请创建一个名为Dockerfile (无扩展名)的文本文件,并使用以下行填充它:
FROM mcr.microsoft.com/azure-cognitive-services/luis:latest
ENV Eula=accept
ENV Billing={ENDPOINT_URI}
ENV ApiKey={API_KEY}
COPY ./{luisAppId}_PRODUCTION.gz /input/{luisAppId}_PRODUCTION.gz您可以使用普通的{ENDPOINT_URI}和{API_KEY}找到您的{luisAppId},当然,{luisAppId}将以您的.gz文件的名称找到。一旦您的Dockerfile准备就绪,使用以下命令从包含您的.gz文件的同一个文件夹运行它:
docker build -t luis .你的形象现在就准备好了。您的队友所要做的就是运行以下命令:
docker run --rm -it -p 5000:5000
--memory 4g
--cpus 2
--mount type=bind,src={OUTPUT_FOLDER},target=/output luis只要{OUTPUT_FOLDER}存在,它就可以是您想要的任何本地绝对路径。如果不需要任何日志记录,也可以省略输出挂载:
docker run --rm -it -p 5000:5000 --memory 4g --cpus 2 luishttps://stackoverflow.com/questions/58866398
复制相似问题