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

无法通过apt-key添加Docker GPG密钥问题求助

Troubleshooting Missing "OK" When Adding Docker's GPG Key

Hey there, I’ve run into this exact hiccup before—let’s walk through some practical fixes to get that key added properly:

Step 1: First, confirm curl is actually fetching the key

Run the curl portion of the command alone to rule out network or URL issues:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg
  • If you see a long block of jumbled text (that’s the GPG key), the problem lies with the apt-key add step.
  • If you get no output at all, check your network:
    • Test connectivity with ping download.docker.com
    • If you’re behind a proxy, set temporary proxy variables like export https_proxy=http://your-proxy:port before running curl

Step 2: Skip the pipe to see clear error messages

Piping commands can hide useful error details. Try saving the key to a file first, then adding it:

# Save the key locally
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o docker-key.gpg

# Add the key via apt-key
sudo apt-key add docker-key.gpg

This will show you explicit errors if something’s off—like permission problems or a corrupted key file.

Heads up: apt-key is deprecated in newer Ubuntu releases. Docker now suggests storing keys in /etc/apt/keyrings instead. Try this more secure approach:

# Create the keyrings directory if it doesn’t exist
sudo mkdir -p /etc/apt/keyrings

# Download and "dearmor" the GPG key (convert to binary format)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

# Set permissions so apt can read the key
sudo chmod a+r /etc/apt/keyrings/docker.gpg

This method avoids the deprecated apt-key tool entirely and is less likely to throw silent errors.

Step 4: Check if apt-key is installed (rare but possible)

Some minimal Ubuntu setups might not include apt-key by default. Verify it exists:

apt-key --version

If you get a "command not found" error, install it with:

sudo apt update && sudo apt install apt-utils

内容的提问来源于stack exchange,提问作者Hassine H'maied

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:15:35