Search code examples
pythondockergithub-actionsdockerhub

buildx failed with: error: cache export feature is currently not supported for docker driver


I have been trying to setup a CI pipeline through Github Actions to docker-hub.

I have written the following .yml file part of .github\workflow and getting the error as indicated below in Build and Push step of the job.

I have tried to find it on Internet but I could not able to find it.

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 }}  

My dockerfile is

# 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"]

The following is the error, when I build on 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")

Solution

  • You'll need something like this in your yml workflow file:

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

    You can see a complete example at Configuring your GitHub Action builder