How to use job.env in container.volume for GitHub actios

In workflow i have defined some job level env variables, and i want to use them in container.volume like matrix, such as:

  build:
    name: build
    needs: lint
    runs-on: self-hosted
    strategy:
      fail-fast: false
      matrix:
        os:
          - centos7
          - ubuntu2004
        compiler:
          - gcc-9.2
          - clang-10
        exclude:
          - os: centos7
            compiler: clang-10
    env:
      CCACHE_DIR: /tmp/ccache/nebula/${{ matrix.os }}-${{ matrix.compiler }}
      CCACHE_MAXSIZE: 8G
    container:
      image: vesoft/nebula-dev:${{ matrix.os }}
      volumes:
        - ${{ env.CCACHE_DIR }}:${{ env.CCACHE_DIR }}
      options: --cap-add=SYS_PTRACE

but some errors are thrown:

Is there any docs to describe why not to use the job.<job_id>.env same as matrix.os?