Sign a tag as a signer
In this step, we will explore how a designated "signer" can sign a Docker image tag. In a real-world scenario, a repository might have multiple signers, each responsible for signing specific tags or releases. This allows for a more distributed and secure signing process.
First, ensure Docker Content Trust is enabled:
export DOCKER_CONTENT_TRUST=1
Now, let's create a new tag for our image, simulating a different version or release that a signer might be responsible for.
docker tag labexuser/my-signed-image:latest labexuser/my-signed-image:v1.0.0
This creates a new tag labexuser/my-signed-image:v1.0.0
pointing to the same image.
To sign this new tag as a different "signer", we use the docker trust sign
command. This command allows you to explicitly sign a specific tag with a specific key.
docker trust sign labexuser/my-signed-image:v1.0.0
When you execute this command, Docker will prompt you for the passphrase of the signing key you want to use. If you are using the same key generated in Step 2, enter that passphrase. If you were a different signer with a different key, you would use that key's passphrase.
After successfully entering the passphrase, Docker will sign the labexuser/my-signed-image:v1.0.0
tag. You should see output confirming the signing process.
Finally, we need to push the updated trust data to the registry. The docker push
command for the signed tag will include the new signature information.
docker push labexuser/my-signed-image:v1.0.0
This command pushes the v1.0.0
tag along with its associated signature to the registry.