英文:
Why am I getting absolute path WORKDIR dockerfile vulnerability warning from Gitlab?
问题
以下是已翻译的代码部分:
1 FROM {docker-image1}
2 HEALTHCHECK CMD curl --fail -s http://localhost:8080/liveliness || exit 1
3 WORKDIR /app
4
5 FROM {docker-image2} AS build
6 WORKDIR /app/src
7 COPY 【项目路径字符串1】, 【项目路径字符串2】
8 RUN dotnet restore --runtime linux-x64 【项目路径字符串1】
9 COPY . .
10 WORKDIR "/app/src/{目录名称}"
11 RUN dotnet build --runtime linux-x64 【项目名称】 -c Release -o /app/build
12
13 FROM build AS publish
14 RUN dotnet publish --runtime linux-x64 【项目名称】 -c Release -o /app/publish
15
16 FROM base AS final
17 WORKDIR /app
18 COPY --from=publish /app/publish .
19
20 ENTRYPOINT ["dotnet", "{项目名称}.dll"]
英文:
I have the following dockerfile for a project that is hosted with Kubernetes and Openshift and am getting a vulnerability warning from Gitlab that line 10 should use an absolute path instead of relative path for the sake of clarity and reliability. Is there something about a string path that dockerfile or Gitlab doesn't like? I am not getting the warnings for lines 3, 6, or 17. NOTE: I've replaced the docker image and project names below with placeholders surrounded by brackets.
1 FROM {docker-image1}
2 HEALTHCHECK CMD curl --fail -s http://localhost:8080/liveliness || exit 1
3 WORKDIR /app
4
5 FROM {docker-image2} AS build
6 WORKDIR /app/src
7 COPY ["{proj-path-string1}", "{proj-path-string2}"]
8 RUN dotnet restore --runtime linux-x64 "{proj-path-string1}"
9 COPY . .
10 WORKDIR "/app/src/{directory-name}"
11 RUN dotnet build --runtime linux-x64 "{project-name}" -c Release -o /app/build
12
13 FROM build AS publish
14 RUN dotnet publish --runtime linux-x64 "{project-name}" -c Release -o /app/publish
15
16 FROM base AS final
17 WORKDIR /app
18 COPY --from=publish /app/publish .
19
20 ENTRYPOINT ["dotnet", "{project-name}.dll"]```
</details>
# 答案1
**得分**: 1
Delete the quotes from that line, changing:
```WORKDIR "/app/src/{directory-name}"```
To:
```WORKDIR /app/src/{directory-name}```
<details>
<summary>英文:</summary>
Delete the quotes from that line, changing:
WORKDIR "/app/src/{directory-name}"
To:
WORKDIR /app/src/{directory-name}
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论