Add a new signer to the repository
In this step, we will learn how to add a new signer to a Docker repository. This is useful when you want to allow another party or system to sign images for your repository.
Before adding a signer, you need to have a signing key. If you don't have one, you can generate a new key pair using the docker trust key generate
command. For this lab, we will assume you have a key pair.
To add a new signer, we use the docker trust signer add
command. This command requires the name of the new signer, the repository name, and the path to the public key of the new signer.
Let's create a dummy public key file for demonstration purposes. In a real scenario, this would be the public key provided by the new signer.
echo "-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0AQICYQADggEPADRUb2tlbiBmb3IgYSB0ZXN0IHNpZ25lcg==
-----END PUBLIC KEY-----" > ~/project/new_signer.pub
This command creates a file named new_signer.pub
in your ~/project
directory with some dummy public key content.
Now, let's add a new signer named my-new-signer
to a hypothetical repository your-dockerhub-user/my-image
. Replace your-dockerhub-user
with your Docker Hub username if you were doing this with a real repository. For this lab, we will use a placeholder.
docker trust signer add my-new-signer your-dockerhub-user/my-image --key ~/project/new_signer.pub
You will be prompted to enter the password for the repository's root key. This is a security measure to ensure that only authorized users can add signers. Since this is a lab environment and we are not interacting with a real Docker registry, you can enter a dummy password.
After entering the password, the command will add the new signer to the repository's trust data. You should see output indicating that the signer has been added.
Adding signer "my-new-signer" to your-dockerhub-user/my-image...
Successfully added signer "my-new-signer" to your-dockerhub-user/my-image
This command updates the trust data for the specified repository on the Docker registry, adding the public key of the new signer.