2015-07-30 01:16:43 +00:00
<!-- [metadata]>
+++
title = "Automation with content trust"
description = "Automating content push pulls with trust"
keywords = ["trust, security, docker, documentation, automation"]
[menu.main]
parent= "smn_content_trust"
+++
<![end-metadata]-->
# Automation with content trust
2016-04-21 06:05:44 +00:00
Your automation systems that pull or build images can also work with trust. Any automation environment must set `DOCKER_TRUST_ENABLED` either manually or in a scripted fashion before processing images.
2015-07-30 01:16:43 +00:00
## Bypass requests for passphrases
To allow tools to wrap docker and push trusted content, there are two
environment variables that allow you to provide the passphrases without an
expect script, or typing them in:
2015-10-09 19:14:46 +00:00
- `DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE`
- `DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE`
2015-07-30 01:16:43 +00:00
Docker attempts to use the contents of these environment variables as passphrase
for the keys. For example, an image publisher can export the repository `target`
and `snapshot` passphrases:
```bash
2015-10-09 19:14:46 +00:00
$ export DOCKER_CONTENT_TRUST_ROOT_PASSPHRASE="u7pEQcGoebUHm6LHe6"
$ export DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE="l7pEQcTKJjUHm6Lpe4"
2015-07-30 01:16:43 +00:00
```
Then, when pushing a new tag the Docker client does not request these values but signs automatically:
2015-08-13 13:42:26 +00:00
```bash
2015-07-30 01:16:43 +00:00
$ docker push docker/trusttest:latest
The push refers to a repository [docker.io/docker/trusttest] (len: 1)
a9539b34a6ab: Image already exists
b3dbab3810fc: Image already exists
latest: digest: sha256:d149ab53f871 size: 3355
Signing and pushing trust metadata
```
2016-06-07 21:02:39 +00:00
When working directly with the Notary client, it will use its [own set of environment variables ](/notary/reference/client-config.md#environment-variables-optional ).
2015-07-30 01:16:43 +00:00
## Building with content trust
2016-04-21 06:05:44 +00:00
You can also build with content trust. Before running the `docker build` command, you should set the environment variable `DOCKER_CONTENT_TRUST` either manually or in a scripted fashion. Consider the simple Dockerfile below.
2015-07-30 01:16:43 +00:00
2015-08-13 13:42:26 +00:00
```Dockerfile
2015-07-30 01:16:43 +00:00
FROM docker/trusttest:latest
RUN echo
```
The `FROM` tag is pulling a signed image. You cannot build an image that has a
`FROM` that is not either present locally or signed. Given that content trust
data exists for the tag `latest` , the following build should succeed:
```bash
$ docker build -t docker/trusttest:testing .
Using default tag: latest
latest: Pulling from docker/trusttest
b3dbab3810fc: Pull complete
a9539b34a6ab: Pull complete
Digest: sha256:d149ab53f871
```
If content trust is enabled, building from a Dockerfile that relies on tag without trust data, causes the build command to fail:
```bash
$ docker build -t docker/trusttest:testing .
unable to process Dockerfile: No trust data for notrust
```
## Related information
2016-03-18 23:11:37 +00:00
* [Content trust in Docker ](content_trust.md )
2015-10-09 23:50:41 +00:00
* [Manage keys for content trust ](trust_key_mng.md )
2016-03-18 23:11:37 +00:00
* [Delegations for content trust ](trust_delegation.md )
2015-10-09 23:50:41 +00:00
* [Play in a content trust sandbox ](trust_sandbox.md )
2015-07-30 01:16:43 +00:00