The difference between the request time and the current time is too large.の対処

参考

エラー

An error occurred (RequestTimeTooSkewed) when calling the PutObject operation: The difference between the request time and the current time is too large.

原因は、コンテナ内の時間のずれのようです。

状況

コンテナ内からS3の操作を行った際に発生。
Docker には Docker Desktop を使用。

対応

もしコンテナに時間設定をしていないのであれば docker-compose.yml に以下を追加する。

environment:
  TZ: Asia/Tokyo

それでも直らない場合は、Docker Desktop を動かしている WSL の問題なので以下のコマンドを実行する。

sudo hwclock --hctosys
YouTube