How do I sign and verify images for Docker Compose?

Learn how to sign and verify images for Docker Compose, ensuring the integrity and authenticity of your container images. This guide provides step-by-step instructions and examples to enhance your DevOps practices.
Docker Compose, image signing, image verification, DevOps, container security
# Generate a private key
openssl genrsa -out private.pem 2048

# Generate a public key
openssl rsa -in private.pem -outform PEM -pubout -out public.pem

# Sign the Docker image with the private key
docker trust signer add --key private.pem my-image:tag

# Verify the Docker image with the public key
docker trust inspect --pretty my-image:tag
        

Docker Compose image signing image verification DevOps container security