buildx 失败并显示:错误:docker 驱动程序当前不支持缓存导出功能

问题描述 投票:0回答:1

我一直在尝试通过

Github Actions
docker-hub
设置 CI 管道。

我已经编写了以下

.yml
文件部分
.github\workflow
并在作业的
Build and Push
步骤中收到如下所示的错误。

我尝试在互联网上找到它,但找不到。

name: Build and Deploy Code
on: [push, pull_request]

jobs:
  job1:
    # This will tell the job to run on ubuntu machine
    runs-on: ubuntu-latest
    env:
      DB_USER: postgres
      DB_PASSWORD: root123
      DB_HOST: postgres
      DB_PORT: 5432
      DATABASE: postgres
      SECRET_KEY: 09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7
      ALGORITHM: HS256
      ACCESS_TOKEN_EXPIRE_DAYS: 300
      REDIS_HOST: redis
      REDIS_PORT: 6379
    services:
      postgres:
        image: postgres
        env:
          POSTGRES_PASSWORD: root123
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

      redis:
        image: redis #Docker hub image
        options: >- #Set health checks to wait until redis has started
          --health-cmd "redis-cli ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 6379:6379
    steps:
      - name: running git repo
        uses: actions/checkout@v3 # from marketplace

      - name: install python version 3.9
        uses: actions/setup-python@v2

      - name: update pip
        run: python -m pip install --upgrade pip

      - name: Install all dependencies
        run: pip install -r backend/requirements.txt

      - name: login to docker-hub
        uses: docker/login-action@v1
        with:
          username: pankeshpatel
          password: Access-token


      - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          context: ./
          file: ./Dockerfile
          builder: ${{ steps.buildx.outputs.name }}
          push: true
          tags: pankeshpatel/bmw:latest
          cache-from: type=local, src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache

      - name: Image digest
        run: echo ${{ steps.docker_build.outputs.diget }}  

我的dockerfile是

# Use an existing image as a base
FROM python:3.9.7


WORKDIR /usr/src/app

COPY requirements.txt  ./
RUN pip install --no-cache-dir -r requirements.txt


COPY .  .   
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

以下是我在 github actions 上构建时出现的错误

/usr/bin/docker buildx build --cache-from type=local, src=/tmp/.buildx-cache --cache-to type=local,dest=/tmp/.buildx-cache --file ./Dockerfile --iidfile /tmp/docker-build-push-XZhTaT/iidfile --tag pankeshpatel/bmw:latest --metadata-file /tmp/docker-build-push-XZhTaT/metadata-file --push ./

error: cache export feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
Error: buildx failed with: error: cache export feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
python docker github-actions dockerhub
1个回答
11
投票

您的 yml 工作流程文件中需要类似的内容:

  -
    name: Set up Docker Buildx
    uses: docker/setup-buildx-action@v3

您可以在配置 GitHub Action 构建器

查看完整示例
© www.soinside.com 2019 - 2024. All rights reserved.