概要
通信ブロッキングツール(お仕事中にえっちなサイトとか見れなくするやつ)を導入済みのWindows PCのWSL(Debian)で、Dockerイメージのビルドを実行した際に、ホスト側のWindowsにインストールされたブロッキングツールの証明書を参照出来ないため、 cdn.amazonlinux.comとかのSSL証明書チェーンを信頼出来ないと怒られて、WSL上でのDockerビルドがブロックされてしまう、という問題が発生したので対処した時のメモ
エラー: ファイル内容(修正前)
amazonlinuxにssm-agentを入れただけの単純なやつ
Dockerfile
1 | FROM public.ecr.aws/amazonlinux/amazonlinux:2023 |
services:
amazonlinux-with-ssm-agent:
image: amazonlinux-with-ssm-agent:latest
build:
context: .
1 |
|
$ docker -v
Docker version 28.5.1, build e180ab8
$ docker compose build
[+] Building 5.2s (6/6) FINISHED
=> [internal] load local bake definitions 0.0s
=> => reading from stdin 591B 0.0s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 341B 0.0s
=> [internal] load metadata for public.ecr.aws/amazonlinux/amazonlinux:2023 1.6s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> CACHED [1/2] FROM public.ecr.aws/amazonlinux/amazonlinux:2023@sha256:f5ca6cafc706233c641ad838e738047389943afd3585cb1df7eedfc4d9b1799d 0.1s
=> => resolve public.ecr.aws/amazonlinux/amazonlinux:2023@sha256:f5ca6cafc706233c641ad838e738047389943afd3585cb1df7eedfc4d9b1799d 0.0s
=> ERROR [2/2] RUN yum update -y && yum install -y amazon-ssm-agent && yum clean all 3.1s
[2/2] RUN yum update -y && yum install -y amazon-ssm-agent && yum clean all:
1.751 Amazon Linux 2023 repository 0.0 B/s | 0 B 00:01
1.752 Errors during downloading metadata for repository ‘amazonlinux’:
1.752 - Curl error (60): SSL peer certificate or SSH remote key was not OK for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.9.20251117/x86_64/mirror.list?instance_id=none [SSL certificate problem: unable to get local issuer certificate]
1.752 Error: Failed to download metadata for repo ‘amazonlinux’: Cannot prepare internal mirrorlist: Curl error (60): SSL peer certificate or SSH remote key was not OK for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.9.20251117/x86_64/mirror.list?instance_id=none [SSL certificate problem: unable to get local issuer certificate]
1.752 Ignoring repositories: amazonlinux
1.853 Dependencies resolved.
1.854 Nothing to do.
1.855 Complete!
2.956 Amazon Linux 2023 repository 0.0 B/s | 0 B 00:00
2.956 Errors during downloading metadata for repository ‘amazonlinux’:
2.956 - Curl error (60): SSL peer certificate or SSH remote key was not OK for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.9.20251117/x86_64/mirror.list?instance_id=none [SSL certificate problem: unable to get local issuer certificate]
2.956 Error: Failed to download metadata for repo ‘amazonlinux’: Cannot prepare internal mirrorlist: Curl error (60): SSL peer certificate or SSH remote key was not OK for https://cdn.amazonlinux.com/al2023/core/mirrors/2023.9.20251117/x86_64/mirror.list?instance_id=none [SSL certificate problem: unable to get local issuer certificate]
2.957 Ignoring repositories: amazonlinux
2.958 No match for argument: amazon-ssm-agent
2.972 Error: Unable to find a match: amazon-ssm-agent
Dockerfile:7
6 |
7 | >>> RUN yum update -y
8 | >>> && yum install -y amazon-ssm-agent
9 | >>> && yum clean all
10 |
failed to solve: process “/bin/sh -c yum update -y && yum install -y amazon-ssm-agent && yum clean all” did not complete successfully: exit code: 1
1 | #### どうしたらいいの? |
services:
amazonlinux-with-ssm-agent:
image: amazonlinux-with-ssm-agent:latest
build:
context: .
secrets: // 追加
- hoge_ca // 追加
// 追加
secrets:
hoge_ca:
file: /usr/local/share/ca-certificates/hoge.crt // [対処1]でエクスポートしてきた証明書(hoge.crt)
1 |
|
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
RUN –mount=type=secret,id=hoge_ca,target=/etc/pki/ca-trust/source/anchors/hoge.crt
update-ca-trust extract
&& yum update -y
&& yum install -y amazon-ssm-agent
&& yum clean all
CMD [“tail”, “-f”, “/dev/null”]
1 |
|
$ docker compose build
1 |
|
$ dc run –rm amazonlinux-with-ssm-agent ls -a /etc/pki/ca-trust/source/anchors/hoge.crt
ls: cannot access ‘/etc/pki/ca-trust/source/anchors/hoge.crt’: No such file or directory