Han*_*nny 5 ssl curl docker docker-compose
我有一个docker-compose.yaml如下所示的小文件(它用于启动本地测试环境):
version: '2'
services:
ubuntu:
build:
context: ./build
dockerfile: ubuntu.dock
volumes:
- ./transfer:/home/
ports:
- "60000:22"
python:
build:
context: ./build
dockerfile: python.dock
volumes:
- .:/home/code
links:
- mssql
- ubuntu
mssql:
image: "microsoft/mssql-server-linux"
environment:
SA_PASSWORD: "somepassword"
ACCEPT_EULA: "Y"
ports:
- "1433:1433"
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我运行时docker-compose up,它在此步骤失败(位于文件中python.dock):
Step 10/19 : RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
---> Running in e4963c91a05b
Run Code Online (Sandbox Code Playgroud)
错误看起来像这样:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
More details here: http://curl.haxx.se/docs/sslcerts.html
Run Code Online (Sandbox Code Playgroud)
文件中失败的部分python.dock如下所示:
# This line fails
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update -y
Run Code Online (Sandbox Code Playgroud)
我过去曾遇到过curl / docker的问题 - 因为我们使用自签名证书在防火墙级别进行解密/加密(网络要求);有没有办法让我指定一个自签名证书供容器使用?
这将允许curl 联系并下载所需的文件。
我尝试过运行类似的东西docker-compose -f docker-compose.yaml --tlscert ~/certs/the-self-signed-ca.pem up,但失败了。
我怎样才能以更编程的方式做到这一点,以便我可以运行docker-compose up?
如果我理解正确的话,您的防火墙会破坏 TLS 加密并使用本地 CA 的证书重新加密。我认为这通常是一个糟糕的情况,你应该以适当的端到端为目标,但不考虑政治。
--tlscert传递给的参数docker-compose用于与 docker 守护进程通信,该守护进程可能远程运行,默认在端口 2376 上公开。在这种情况下,您的本地docker-compose命令会在远程计算机上编排容器,包括构建映像。
在您的情况下,该curl命令在容器内运行。它将使用(通常)由python.dock. 要使用您的自定义 CA,您需要
将 CA 证书复制到映像中的正确位置,例如
COPY the-self-signed-ca.pem /etc/ssl/certs/
Run Code Online (Sandbox Code Playgroud)
确切的过程取决于您的基础映像。这将使证书在容器中可用。该证书很可能会被所有后续流程使用。其他开发人员/用户可能不知道安装了自定义 CA 并且连接不安全!
将 CA 证书复制到映像中的自定义位置,例如
COPY the-self-signed-ca.pem /some/path/the-self-signed-ca.pem
Run Code Online (Sandbox Code Playgroud)
并使用参数明确告诉curl有关自定义CA的信息--cacert:
RUN curl --cacert /some/path/the-self-signed-ca.pem https://example.com/
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
34762 次 |
| 最近记录: |