LoginSignup
2
0

More than 3 years have passed since last update.

Docker for Windowsで時刻ズレ対策

Posted at

概要

事故用メモ

  1. WSL2をバックエンドにしたDockerDesktopでaptがRelease file for is not valid yetエラーを吐いた。

  2. WSL2統合されたDocker for WindowsでaptがRelease file for xxx is not valid yetなエラーになった場合の対処
    の記事に記載の方法であるwsl -d可能なディストリに対してhwclock -sしても解決しない場合の対策として、コンテナ内で時刻調整が有効だった。

バージョン

Windows 10 build 19042
Docker Desktop 2.5.0.1

事象と解決手段

事象

ubuntu:20.04コンテナに対して以下のコマンドを実行

apt install build-essential

結果、Release file for xxx is not valid yetエラー(ログを取り損ねたのがおそらくlibc6)。

WSL側の時刻ズレが原因との記事が多く見られたので以下のコマンドを実行したが解決せず。

wsl -d docker-desktop
hwclock -s

解決手段

WSL側ではなくコンテナ側でntpdateによる時刻合わせを行い解決を図ることにした。

ntpdate ntp.nict.jp

を叩くもCan't adjust the time of day: Operation not permittedと怒られた。これはコンテナに権限が不足していることに起因している。

docker run--privilagedオプションを渡して解決。

docker run -itd --privilaged --name hoge ubuntu:20.04 

権限が多すぎるので危険だけど趣味環境なのでとりあえずこれで解決とする。(SYS_TIME, NET_ADMINだけでは不足だった)

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0