Atleast one invalid signature was encountered

I had the same problem. It looks like it was lack of space. I've removed old images and it started to work.

$ docker images

Select the ones you don't care anymore (to delete).

$ docker rmi <image_id>

The following command filter the dangling images and remove those.

docker rmi $(docker images -q --filter "dangling=true")

I had this same issue and none of the previous responses saying to prune images or containers worked. The reason was that my Docker Build Cache was taking up the bulk of the space. Running the below command fixed the issue:

docker system prune

You can then check to see if it worked by running:

docker system df


The above command will clear the whole Docker system. If you want to clear only the build cache, you can do it with the below command (credit to saraf.gahl):

docker builder prune

The reason I usually see this is because docker has run out of disk space, which is frustrating because the error gives little indication that this is the problem. First try cleaning up images and containers you don't need using the prune command

$ docker image prune 
$ docker container prune 

If you have a lot of images accumulated and want to remove all of them that aren't associated with an existing container try:

$ docker image prune -a 

Or you can remove only older images:

$ docker image prune -a --filter "until=24h"

Finally, on MacOS, where Docker runs inside a dedicated VM, you may need to increase the disk available to Docker from the Docker Desktop application (Settings -> Resources -> Advanced -> Disk image size).

There are a few reasons why you encounter these errors:

  1. There might be an issue with the existing cache and/or disc space. In order to fix it you need to clear the APT cache by executing: sudo apt-get clean and sudo apt-get update.

  2. The same goes with existing docker images. Execute: docker image prune -f and docker container prune -f in order to remove unused data and free disc space.

  3. If you don't care about the security risks, you can try to run the apt-get command with the --allow-unauthenticated or --allow-insecure-repositories flag. According to the docs:

Ignore if packages can't be authenticated and don't prompt about it. This can be useful while working with local repositories, but is a huge security risk if data authenticity isn't ensured in another way by the user itself.

Please let me know if that helped.