You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell中使用TLS证书访问Docker Daemon的Curl请求方法

在PowerShell中访问Docker Daemon的证书请求命令

PowerShell里的curl是Invoke-WebRequest的别名,参数规则和Linux原生curl完全不同,直接用原命令自然会报错。这里提供两种可行的解决方法:

方法一:调用Windows自带的curl.exe

Windows 10及以上版本默认自带原生curl程序,你只需在PowerShell里明确调用curl.exe(而非curl别名),就能沿用类似Linux的参数格式:

curl.exe https://192.168.99.102:2376/images/json --cert cert.pem --key key.pem --cacert ca.pem

方法二:使用PowerShell原生的Invoke-WebRequest

PowerShell的Invoke-WebRequest仅支持PFX格式的证书,所以需要先将你的PEM证书和密钥合并为PFX文件(用OpenSSL工具):

openssl pkcs12 -export -out client.pfx -inkey key.pem -in cert.pem

执行时会提示设置PFX文件的密码,记住这个密码。

之后用PowerShell命令发起请求:

# 加载客户端证书(输入之前设置的PFX密码)
$clientCert = Get-PfxCertificate -FilePath .\client.pfx
# 加载CA证书
$caCert = Get-PfxCertificate -FilePath .\ca.pem

Invoke-WebRequest -Uri "https://192.168.99.102:2376/images/json" -Certificate $clientCert -CaCertificate $caCert

内容的提问来源于stack exchange,提问作者bogonemil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 14:12:03