Keywords: Docker build error | GPG signature verification | Disk space management
Abstract: This paper provides an in-depth analysis of the GPG signature verification errors encountered when building microservice images with Skaffold in Kubernetes development environments. The article systematically examines the root cause of this issue—primarily insufficient Docker system resources (especially disk space) preventing APT package manager from properly verifying software repository signatures. By integrating solutions from multiple technical communities, the paper presents a multi-layered approach to resolution, ranging from cleaning APT caches and Docker images/containers to managing Docker build caches. Special emphasis is placed on the critical role of docker system prune and docker builder prune commands in freeing disk space, while also discussing the security risks of the --allow-unauthenticated flag. The article offers practical diagnostic commands and best practice recommendations to help developers effectively prevent and resolve such build issues in cloud-native development workflows.
Problem Context and Error Analysis
In cloud-native application development, using Skaffold to build and deploy microservices to Kubernetes clusters has become standard practice. However, developers frequently encounter a specific build error when constructing Google Cloud Platform's Online Boutique microservice demo application: during Docker image building, the APT package manager reports "At least one invalid signature was encountered." This error typically occurs when executing the apt-get update command, manifesting specifically as:
W: GPG error: http://deb.debian.org/debian buster InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed.
The error message indicates that GPG signature verification for Debian software repositories has failed, preventing APT from securely updating package lists. The root cause of this problem is often not network connectivity or repository configuration issues, but rather resource constraints in the Docker environment.
Root Cause Investigation
Through analysis of discussions across multiple technical communities, we have identified that the primary trigger for this GPG signature verification error is insufficient Docker system disk space. When Docker's storage space approaches exhaustion, although the error message points to signature verification issues, the actual problem is the system's inability to properly complete the download and verification process of package indexes. This situation is particularly common in continuous integration/continuous deployment (CI/CD) pipelines, as frequent image builds rapidly accumulate large amounts of intermediate layers, cache data, and unused images.
Specifically, the following factors may contribute to disk space depletion:
- Uncleaned APT caches: The
/var/cache/apt/archivesdirectory in Docker containers may accumulate numerous .deb package files - Unused Docker images: Temporary images and old version images generated during development occupy significant space
- Stopped containers: Container instances that have completed tasks but haven't been cleaned up
- Build caches: Intermediate layers and cache data generated during Docker build processes—the most overlooked but space-consuming component
Systematic Solution Approach
Step 1: Clean APT Caches
First address APT cache issues within containers. During Dockerfile construction, add cleanup instructions before and after the apt-get update command:
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get update \
&& apt-get install -y --no-install-recommends curl
This approach ensures each build starts from a clean APT state, preventing cache accumulation issues.
Step 2: Manage Docker Storage Space
This is the core step in resolving this issue. Based on best practices from technical communities, we recommend the following cleanup strategy:
2.1 Basic Cleanup Commands
Execute the following commands to clean unused Docker resources:
# Clean unused images
$ docker image prune -f
# Clean stopped containers
$ docker container prune -f
# Selectively delete specific images (via IMAGE-ID)
$ docker rmi -f <IMAGE-ID1> <IMAGE-ID2>
2.2 Comprehensive System Cleanup
When basic cleanup proves insufficient, use the docker system prune command for more thorough cleaning:
# Clean all unused Docker resources (images, containers, networks, build caches)
$ docker system prune -a
This command removes all resources not referenced by containers, including dangling images and build caches. After execution, use docker system df to verify disk usage.
2.3 Targeted Build Cache Cleanup
If you wish to preserve other Docker resources while only cleaning build caches, use the specialized builder cleanup command:
# Clean only Docker build caches
$ docker builder prune
This command is particularly suitable for CI/CD environments as it doesn't affect running containers and base images.
2.4 Advanced Cleanup Strategies
For environments requiring finer control, use filters and time parameters:
# Clean unused images older than 24 hours
$ docker image prune -a --filter "until=24h"
# View detailed Docker disk usage
$ docker system df -v
Step 3: Temporary Solutions and Security Warnings
In certain emergency situations, developers might consider using the --allow-unauthenticated flag to bypass signature verification:
RUN apt-get update --allow-unauthenticated \
&& apt-get install -y --no-install-recommends curl
Important Warning: This method carries significant security risks. According to Debian official documentation, this flag "ignores if packages can't be authenticated and doesn't prompt about it." While this may temporarily resolve issues in local development environments, using it in production could lead to installation of unverified packages, introducing security vulnerabilities. We recommend using this only as a temporary debugging measure and removing the flag immediately after resolution.
Preventive Measures and Best Practices
1. Regular Maintenance Strategy
Establish regular Docker system maintenance schedules:
- Add post-build cleanup steps to CI/CD pipelines
- Set up scheduled tasks to automatically clean old images and build caches
- Monitor Docker disk usage and set warning thresholds
2. Docker Desktop Configuration Optimization (macOS Environment)
For macOS users utilizing Docker Desktop, virtual machine disk configuration adjustments may be necessary:
- Open the Docker Desktop application
- Navigate to Settings → Resources → Advanced
- Adjust "Disk image size" to a larger value (e.g., 64GB or 128GB)
- Apply changes and restart Docker
3. Build Optimization Techniques
Adopt best practices when writing Dockerfiles:
# Use multi-stage builds to reduce final image size
FROM debian:buster-slim as builder
# ... build steps ...
FROM debian:buster-slim
# Copy only necessary files
COPY --from=builder /app /app
# Combine APT commands to reduce layers
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
Diagnostic and Troubleshooting Process
When encountering similar issues, we recommend following this diagnostic process:
- Check disk space: Use
docker system dfto view detailed usage - Verify network connectivity: Ensure normal access to Debian repositories
- Check system time: Verify time synchronization between Docker containers and host system—GPG signature verification is time-sensitive
- Progressive cleanup: Execute cleanup commands in the order presented in this article
- Rebuild build cache: In extreme cases, complete reconstruction of the Docker build environment may be necessary
Conclusion
The "At least one invalid signature was encountered" error, while superficially appearing as a GPG signature verification issue, fundamentally stems from improper Docker system resource management—particularly insufficient disk space. Through systematic cleanup strategies and preventive measures, developers can effectively resolve and avoid this problem. Key takeaways include: prioritizing docker system prune and docker builder prune for space management, exercising caution with the --allow-unauthenticated flag, and establishing regular maintenance routines. In cloud-native development practices, proper Docker resource management not only resolves build errors but also enhances development efficiency and system stability.