In some cases such as passing .docker/config.json to a container, you would mount /root/.docker as read-only. But this makes buildx wrong due to mkdir /root/.docker/buildx: read-only file system
. The thing is, buildx is the default of docker 23.
I found that specifying BUILDX_CONFIG (eg BUILDX_CONFIG=/tmp/buildx
) can resolve this issue. /tmp/buildx will be gone after exiting the container, but saving persistent config of buildx inside container is not useful anyway.
For my reference later, this is how I found the solution:
- ~/.docker/buildx/activity の存在を思い出す
- https://docs.docker.com/build/release-notes/#0100 から https://github.com/docker/buildx/pull/1439 を発見する
- https://github.com/docker/buildx/blob/v0.10.4/store/store.go のNewで失敗していることを把握する
- https://github.com/docker/buildx/blob/v0.10.4/store/storeutil/storeutil.go
- https://github.com/docker/buildx/blob/v0.10.4/util/confutil/config.go とたどり、当該Newの引数はBUILDX_CONFIGでオーバーライドできることを把握する
(我ながら目茶苦茶なたどり方だなぁ)