buildx失败了错误:“没有此类文件或目录”。试图在github上推码头时

发布于 2025-02-08 21:41:26 字数 2058 浏览 0 评论 0原文

我是Docker的新手,当我推动更新时,我正在尝试使用Docker设置我的GitHub存储库。但是,当Github WorkFile脚本将我的代码推到Docker时,我会收到以下错误。

Error: buildx failed with: error: failed to solve: failed to compute cache key: failed to walk /var/lib/docker/tmp/buildkit-mount1164878607/target: lstat /var/lib/docker/tmp/buildkit-mount1164878607/target: no such file or directory

看来Docker无法在Dockerfile中访问我为其设置的文件,但对代码的调整似乎没有修复,但对于我来说,完全删除了副本标签,这使我的Docker无法兑现,尽管它确实发送了。我正在使用Maven编译器插件以及Maven Shade插件,并相应地设置了我的pom.xml文件。

这是我的github workfile:

name: Docker

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
      
    - name: Set up JDK
      uses: actions/[email protected]
      with:
        java-version: 18
        distribution: adopt

    - name: Build with Maven
      run: mvn clean package
      
    - name: Login to DockerHub
      uses: docker/[email protected]
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_TOKEN }}

    - name: Build and push Docker images
      uses: docker/[email protected]
      with:
        push: true
        tags: sudden/discordbot:latest
      

这是我的dockerfile:

FROM openjdk:11-jdk-slim
WORKDIR /tmp
COPY target/discordbot-1.0-SNAPSHOT-shaded.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/app.jar"]

我尝试过的内容:

  • 在我的“ src”目录中复制另一个随机文件。
  • 更改我的罐子文件的名称并更改路径。
  • 改变我的工作迪尔。
  • 在我的工作文件中更改了Docker的“上下文”和其他标签。

任何帮助都将受到赞赏。这可能是一个简单的解决方案,但是尽管我尽了最大的努力,但我还是被困了一天,所以在这里询问是最后的手段。谢谢。

I'm very new to Docker and I'm trying to get my Github repository setup with a docker when I push an update. However, when the github workfile script goes to push my code to Docker I get the following error.

Error: buildx failed with: error: failed to solve: failed to compute cache key: failed to walk /var/lib/docker/tmp/buildkit-mount1164878607/target: lstat /var/lib/docker/tmp/buildkit-mount1164878607/target: no such file or directory

It appears Docker can't access the file I set for it in my Dockerfile yet no amount of tweaking with the code appears to fix it, aside for me completely removing the COPY tag which renders my Docker unrunnable, though it does send. I'm using maven compiler plugin along with maven shade plugin and have setup my pom.xml file accordingly.

Here is my Github WorkFile:

name: Docker

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
      
    - name: Set up JDK
      uses: actions/[email protected]
      with:
        java-version: 18
        distribution: adopt

    - name: Build with Maven
      run: mvn clean package
      
    - name: Login to DockerHub
      uses: docker/[email protected]
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_TOKEN }}

    - name: Build and push Docker images
      uses: docker/[email protected]
      with:
        push: true
        tags: sudden/discordbot:latest
      

Here is my DockerFile:

FROM openjdk:11-jdk-slim
WORKDIR /tmp
COPY target/discordbot-1.0-SNAPSHOT-shaded.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/app.jar"]

What I've tried:

  • Copying another random file in my "src" directory.
  • Changing the name of my jar file and changing the path.
  • Changing my WORKDIR.
  • Changed the Docker's "context" and other tags in my Workfile.

Any help is appreciated. This might be a simple fix, but I've been stuck on it for a day despite my best efforts so asking here is a last resort. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

屋顶上的小猫咪 2025-02-15 21:41:26

确保您尚未在.dockerignore文件中排除target文件夹。

经过几天的绝望搜索,这就是我为我解决的问题...

Make sure that you haven't excluded your target folders in your .dockerignore file.

That's what fixed it for me after several days of despairing search...

堇色安年 2025-02-15 21:41:26

我面临着同样的问题,最后是因为在我的github存储库上,文件夹target没有。
推动后,工作流程起作用。

如果有人想用来指导,我将其留在这里我的docker-publish.yml。

name: Generate Docker Image and Publish

on:
  push:
    branches: [ "main" ]
    tags: [ 'v*.*.*' ]
  pull_request:
    branches: [ "main" ]

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          push: true
          tags: laurocorreia/reactive-api:latest

I was facing the same problem and at end it was because on my GitHub repository the folder target was not.
After push it the workflow worked.

I leave it here my docker-publish.yml if some want use to guide.

name: Generate Docker Image and Publish

on:
  push:
    branches: [ "main" ]
    tags: [ 'v*.*.*' ]
  pull_request:
    branches: [ "main" ]

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          push: true
          tags: laurocorreia/reactive-api:latest
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文