起きた問題

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のパスは正しいものとする。
解決策

Dockerfileでca-certificatesをインストールするようにしたら、無事にcloneできるようになった。たとえば、以下のようにする。
Dockerfile
RUN apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
git \
ca-certificatesほかの解決策

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

