Featured image of post Ubuntuのdockerイメージでgit cloneしようとしたら"server certificate verification failed. CAfile: none CRLfile: none"と言われた

Ubuntuのdockerイメージでgit cloneしようとしたら"server certificate verification failed. CAfile: none CRLfile: none"と言われた

この記事は最終更新日から1年以上経過しています。

起きた問題 Link to this heading

Ubuntuのdockerイメージでgit cloneしようとしたら以下のエラーを吐かれてcloneできなかった。

git clone https://github.com/hoge/fuga.git
Cloning into 'fuga'...
fatal: unable to access 'https://github.com/hoge/fuga.git/': server certificate verification failed. CAfile: none CRLfile: none

ただし、https://github.com/hoge/fuga.gitのパスは正しいものとする。

解決策 Link to this heading

Dockerfileでca-certificatesをインストールするようにしたら、無事にcloneできるようになった。たとえば、以下のようにする。

Dockerfile
RUN apt-get update -y \
  && DEBIAN_FRONTEND=noninteractive \
  apt-get install -y --no-install-recommends \
  git \
  ca-certificates

ほかの解決策 Link to this heading

sudoが実行できるユーザーを作成しているなら、コンテナ内でsudo apt install --reinstall ca-certificatesしてもよさそう。

コンテナidがわかっていて、そのコンテナだけ対応させたいなら、rootユーザーでコンテナに入る。

docker exec  -it -u root <container id> bash

その後、コンテナ内にca-certificatesを再度インストールする。

sudo apt install --reinstall ca-certificates

参考文献・URL Link to this heading

No Image
muoilog.xyz にアクセスできません
muoilog.xyz
Licensed under CC BY-NC-SA 4.0
最終更新 2月 24, 2025
Hugo で構築されています。
テーマ StackJimmy によって設計されています。