# W: GPG错误：http://deb.debian.org/debian bullseye InRelease：无法验证签名，因为没有公钥

- **ID:** `docker/gpg-key-expired`
- **领域:** docker
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

Docker构建使用了带有过时apt仓库GPG密钥的缓存基础镜像，导致apt-get update在签名验证时失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Docker 24.0.6 | active | — | — |
| Debian 11 (bullseye) | active | — | — |
| Ubuntu 22.04 | active | — | — |

## 解决方案

1. ```
   添加--no-cache标志强制重建：docker build --no-cache -t my_image .
   ```
2. ```
   更新基础镜像到最新版本：RUN apt-get update && apt-get install -y --allow-unauthenticated gnupg && curl -fsSL https://deb.debian.org/debian/archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/debian-archive-keyring.gpg
   ```

## 无效尝试

- **** — Manually importing the key in Dockerfile with apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <key> often fails because apt-key is deprecated and keyserver may be unreachable. (50% 失败率)
- **** — Removing the entire apt list and retrying without updating the base image still uses the same cached layer with broken keys. (80% 失败率)
