DockerfileでCOPY –chmodした際にthe –chmod option requires BuildKit.エラーが出る場合の対処

エラーの続きは下記のようになっているため

failed to build : the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/ to learn how to build images with BuildKit enabled

該当URLのドキュメントを見ると-COPY –chmodを使うには DOCKER_BUILDKIT=1 が必要な模様

具体的にはDockerfileにENVで指定する

(例)

FROM php:8.1.6-apache-buster

ENV DOCKER_BUILDKIT=1
COPY --chmod 755 ./path/to/file:/container/path/to/file
RUN pecl install redis && docker-php-ext-enable redis

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です