gpt4 book ai didi

windows - 从Docker容器访问Windows文件共享(域)内的伪像

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

所以....
我想知道是否有人可以在这方面协助我?
基本上,我已经创建了一个自托管的Docker容器,用作构建代理(Azure DevOps)
现在,我已经开始测试代理,并且由于我们的放置文件夹位于Windows文件共享(已加入域)的事实,我无法将人工制品发布到目的地时遇到问题
有谁能阐明我如何能够访问此文件共享以从构建中删除 Artifact ,并能够在发布阶段下载它们?
我们使用本地TFS Azure DevOps而非Azure DevOps Services :(
TIA,
更新资料
最后,我能够解决此问题。
解决此问题的方法是,我在域 Controller 上创建了一个gMSA帐户,然后在托管Docker容器的计算机上创建了credspec文件,然后最后我使用以下命令docker run --security-opt "credentialspec=file://<credspecfilename>.json" --hostname <hostname> -it <Image-name> PowerShell运行了该容器
容器启动并运行后,我可以通过运行以下命令dir <server>\\<share>来确认目录是否可用-另外,我还必须确保新创建的gMSA帐户具有共享权限。
因此,我继续将容器加入到我们的DevOps服务器的代理池中,然后运行了一个测试版本。正如预期的那样,我能够从本地加入域的服务器中提取/发布人工制品。
再次感谢大家在这个问题上为我提供帮助。

最佳答案

您可以使用Build.ArtifactStagingDirectory,就像Daniel在评论中提到的那样,将构建 Artifact 发布到服务器。

Build.ArtifactStagingDirectory

The local path on the agent where any artifacts are copied to before being pushed to their destination. For example: c:\agent_work\1\a

A typical way to use this folder is to publish your build artifacts with the Copy files and Publish build artifacts tasks.



详细步骤,您可以引用托马斯·亚伯拉罕(Thomas F. Abraham)在此问题中的答复: How to copy azure pipeline artifacts to a docker image which is microsoft dotnetcore runtime image

  1. Add a Docker task after the publish, configured to "Build"
  2. Set the "Build Context" in the task to $(Build.ArtifactStagingDirectory). That's the root path Docker will use for commands like COPY in a Dockerfile.
  3. Commit a Dockerfile to your repo, and set the Dockerfile path in the task to match its location

Set up the Dockerfile like this (I'm assuming .NET Core 2.2 here):
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 WORKDIR /app COPY . .
ENTRYPOINT ["dotnet", "myAppNameHere.dll"]
Because you've set the Docker Build Context to $(Build.ArtifactStagingDirectory), where your app has been published, the COPY command will use that as a "current working directory." The translation of the COPY is "copy everything in $(Build.ArtifactStagingDirectory) to the /app folder inside the container."

That'll get you a basic Docker container that simply contains your pre-built and published app files.



此外,您还可以选择将这些 Artifact 发布为Nuget包。这样,您可以引用以下博客: Accessing Azure Artifacts from a docker container in a Pipelines build.

关于windows - 从Docker容器访问Windows文件共享(域)内的伪像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60283856/

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