Signed-off-by: Mansi Nahar <mmn4185@rit.edu>
| ... | ... |
@@ -130,7 +130,14 @@ read how to [manage keys for content trust](trust_key_mng.md). |
| 130 | 130 |
## Survey of typical content trust operations |
| 131 | 131 |
|
| 132 | 132 |
This section surveys the typical trusted operations users perform with Docker |
| 133 |
-images. |
|
| 133 |
+images. Specifically, we will be going through the following steps to help us exercise |
|
| 134 |
+these various trusted operations: |
|
| 135 |
+ |
|
| 136 |
+* Build and push an unsigned image |
|
| 137 |
+* Pull an unsigned image |
|
| 138 |
+* Build and push a signed image |
|
| 139 |
+* Pull the signed image pushed above |
|
| 140 |
+* Pull unsigned image pushed above |
|
| 134 | 141 |
|
| 135 | 142 |
### Enable and disable content trust per-shell or per-invocation |
| 136 | 143 |
|
| ... | ... |
@@ -152,14 +159,36 @@ In an environment where `DOCKER_CONTENT_TRUST` is set, you can use the |
| 152 | 152 |
`--disable-content-trust` flag to run individual operations on tagged images |
| 153 | 153 |
without content trust on an as-needed basis. |
| 154 | 154 |
|
| 155 |
-```bash |
|
| 156 |
-$ docker pull --disable-content-trust docker/trusttest:untrusted |
|
| 155 |
+Consider the following Dockerfile that uses an untrusted base image: |
|
| 156 |
+ |
|
| 157 |
+``` |
|
| 158 |
+$ cat Dockerfile |
|
| 159 |
+FROM docker/trusttest:latest |
|
| 160 |
+RUN echo |
|
| 161 |
+``` |
|
| 162 |
+ |
|
| 163 |
+In order to build a container successfully using this Dockerfile, one can do: |
|
| 164 |
+ |
|
| 165 |
+``` |
|
| 166 |
+$ docker build --disable-content-trust -t <username>/nottrusttest:latest . |
|
| 167 |
+Sending build context to Docker daemon 42.84 MB |
|
| 168 |
+... |
|
| 169 |
+Successfully built f21b872447dc |
|
| 170 |
+``` |
|
| 171 |
+ |
|
| 172 |
+The same is true for all the other commands, such as `pull` and `push`: |
|
| 173 |
+ |
|
| 174 |
+``` |
|
| 175 |
+$ docker pull --disable-content-trust docker/trusttest:latest |
|
| 176 |
+... |
|
| 177 |
+$ docker push --disable-content-trust <username>/nottrusttest:latest |
|
| 178 |
+... |
|
| 157 | 179 |
``` |
| 158 | 180 |
|
| 159 | 181 |
To invoke a command with content trust enabled regardless of whether or how the `DOCKER_CONTENT_TRUST` variable is set: |
| 160 | 182 |
|
| 161 | 183 |
```bash |
| 162 |
-$ docker build --disable-content-trust=false -t docker/trusttest:testing . |
|
| 184 |
+$ docker build --disable-content-trust=false -t <username>/trusttest:testing . |
|
| 163 | 185 |
``` |
| 164 | 186 |
|
| 165 | 187 |
All of the trusted operations support the `--disable-content-trust` flag. |
| ... | ... |
@@ -172,8 +201,8 @@ and push a tagged image. If this is the first time you have pushed an image |
| 172 | 172 |
using content trust on your system, the session looks like this: |
| 173 | 173 |
|
| 174 | 174 |
```bash |
| 175 |
-$ docker push docker/trusttest:latest |
|
| 176 |
-The push refers to a repository [docker.io/docker/trusttest] (len: 1) |
|
| 175 |
+$ docker push <username>/trusttest:testing |
|
| 176 |
+The push refers to a repository [docker.io/<username>/trusttest] (len: 1) |
|
| 177 | 177 |
9a61b6b1315e: Image already exists |
| 178 | 178 |
902b87aaaec9: Image already exists |
| 179 | 179 |
latest: digest: sha256:d02adacee0ac7a5be140adb94fa1dae64f4e71a68696e7f8e7cbf9db8dd49418 size: 3220 |
| ... | ... |
@@ -186,9 +215,9 @@ password manager to generate the passphrase and keep it safe. There will be no |
| 186 | 186 |
way to recover this key. You can find the key in your config directory. |
| 187 | 187 |
Enter passphrase for new root key with id a1d96fb: |
| 188 | 188 |
Repeat passphrase for new root key with id a1d96fb: |
| 189 |
-Enter passphrase for new repository key with id docker.io/docker/trusttest (3a932f1): |
|
| 190 |
-Repeat passphrase for new repository key with id docker.io/docker/trusttest (3a932f1): |
|
| 191 |
-Finished initializing "docker.io/docker/trusttest" |
|
| 189 |
+Enter passphrase for new repository key with id docker.io/<username>/trusttest (3a932f1): |
|
| 190 |
+Repeat passphrase for new repository key with id docker.io/<username>/trusttest (3a932f1): |
|
| 191 |
+Finished initializing "docker.io/<username>/trusttest" |
|
| 192 | 192 |
``` |
| 193 | 193 |
When you push your first tagged image with content trust enabled, the `docker` |
| 194 | 194 |
client recognizes this is your first push and: |
| ... | ... |
@@ -202,12 +231,12 @@ client recognizes this is your first push and: |
| 202 | 202 |
The passphrase you chose for both the root key and your repository key-pair |
| 203 | 203 |
should be randomly generated and stored in a *password manager*. |
| 204 | 204 |
|
| 205 |
-> **NOTE**: If you omit the `latest` tag, content trust is skipped. This is true |
|
| 205 |
+> **NOTE**: If you omit the `testing` tag, content trust is skipped. This is true |
|
| 206 | 206 |
even if content trust is enabled and even if this is your first push. |
| 207 | 207 |
|
| 208 | 208 |
```bash |
| 209 |
-$ docker push docker/trusttest |
|
| 210 |
-The push refers to a repository [docker.io/docker/trusttest] (len: 1) |
|
| 209 |
+$ docker push <username>/trusttest |
|
| 210 |
+The push refers to a repository [docker.io/<username>/trusttest] (len: 1) |
|
| 211 | 211 |
9a61b6b1315e: Image successfully pushed |
| 212 | 212 |
902b87aaaec9: Image successfully pushed |
| 213 | 213 |
latest: digest: sha256:a9a9c4402604b703bed1c847f6d85faac97686e48c579bd9c3b0fa6694a398fc size: 3220 |
| ... | ... |
@@ -221,16 +250,16 @@ Once you have a root key on your system, subsequent images repositories |
| 221 | 221 |
you create can use that same root key: |
| 222 | 222 |
|
| 223 | 223 |
```bash |
| 224 |
-$ docker push docker.io/docker/seaside:latest |
|
| 225 |
-The push refers to a repository [docker.io/docker/seaside] (len: 1) |
|
| 224 |
+$ docker push docker.io/<username>/otherimage:latest |
|
| 225 |
+The push refers to a repository [docker.io/<username>/otherimage] (len: 1) |
|
| 226 | 226 |
a9539b34a6ab: Image successfully pushed |
| 227 | 227 |
b3dbab3810fc: Image successfully pushed |
| 228 | 228 |
latest: digest: sha256:d2ba1e603661a59940bfad7072eba698b79a8b20ccbb4e3bfb6f9e367ea43939 size: 3346 |
| 229 | 229 |
Signing and pushing trust metadata |
| 230 | 230 |
Enter key passphrase for root key with id a1d96fb: |
| 231 |
-Enter passphrase for new repository key with id docker.io/docker/seaside (bb045e3): |
|
| 232 |
-Repeat passphrase for new repository key with id docker.io/docker/seaside (bb045e3): |
|
| 233 |
-Finished initializing "docker.io/docker/seaside" |
|
| 231 |
+Enter passphrase for new repository key with id docker.io/<username>/otherimage (bb045e3): |
|
| 232 |
+Repeat passphrase for new repository key with id docker.io/<username>/otherimage (bb045e3): |
|
| 233 |
+Finished initializing "docker.io/<username>/otherimage" |
|
| 234 | 234 |
``` |
| 235 | 235 |
|
| 236 | 236 |
The new image has its own repository key and timestamp key. The `latest` tag is signed with both of |
| ... | ... |
@@ -240,54 +269,27 @@ these. |
| 240 | 240 |
### Pull image content |
| 241 | 241 |
|
| 242 | 242 |
A common way to consume an image is to `pull` it. With content trust enabled, the Docker |
| 243 |
-client only allows `docker pull` to retrieve signed images. |
|
| 243 |
+client only allows `docker pull` to retrieve signed images. Let's try to pull the image |
|
| 244 |
+you signed and pushed earlier: |
|
| 244 | 245 |
|
| 245 | 246 |
``` |
| 246 |
-$ docker pull docker/seaside |
|
| 247 |
+$ docker pull <username>/trusttest:testing |
|
| 247 | 248 |
Using default tag: latest |
| 248 |
-Pull (1 of 1): docker/trusttest:latest@sha256:d149ab53f871 |
|
| 249 |
+Pull (1 of 1): <username>/trusttest:testing@sha256:d149ab53f871 |
|
| 249 | 250 |
... |
| 250 |
-Tagging docker/trusttest@sha256:d149ab53f871 as docker/trusttest:latest |
|
| 251 |
+Tagging <username>/trusttest@sha256:d149ab53f871 as docker/trusttest:testing |
|
| 251 | 252 |
``` |
| 252 | 253 |
|
| 253 |
-The `seaside:latest` image is signed. In the following example, the command does not specify a tag, so the system uses |
|
| 254 |
-the `latest` tag by default again and the `docker/cliffs:latest` tag is not signed. |
|
| 254 |
+In the following example, the command does not specify a tag, so the system uses |
|
| 255 |
+the `latest` tag by default again and the `docker/trusttest:latest` tag is not signed. |
|
| 255 | 256 |
|
| 256 | 257 |
```bash |
| 257 |
-$ docker pull docker/cliffs |
|
| 258 |
+$ docker pull docker/trusttest |
|
| 258 | 259 |
Using default tag: latest |
| 259 | 260 |
no trust data available |
| 260 | 261 |
``` |
| 261 | 262 |
|
| 262 |
-Because the tag `docker/cliffs:latest` is not trusted, the `pull` fails. |
|
| 263 |
- |
|
| 264 |
- |
|
| 265 |
-### Disable content trust for specific operations |
|
| 266 |
- |
|
| 267 |
-A user who wants to disable content trust for a particular operation can use the |
|
| 268 |
-`--disable-content-trust` flag. **Warning: this flag disables content trust for |
|
| 269 |
-this operation**. With this flag, Docker will ignore content-trust and allow all |
|
| 270 |
-operations to be done without verifying any signatures. If we wanted the |
|
| 271 |
-previous untrusted build to succeed we could do: |
|
| 272 |
- |
|
| 273 |
-``` |
|
| 274 |
-$ cat Dockerfile |
|
| 275 |
-FROM docker/trusttest:notrust |
|
| 276 |
-RUN echo |
|
| 277 |
-$ docker build --disable-content-trust -t docker/trusttest:testing . |
|
| 278 |
-Sending build context to Docker daemon 42.84 MB |
|
| 279 |
-... |
|
| 280 |
-Successfully built f21b872447dc |
|
| 281 |
-``` |
|
| 282 |
- |
|
| 283 |
-The same is true for all the other commands, such as `pull` and `push`: |
|
| 284 |
- |
|
| 285 |
-``` |
|
| 286 |
-$ docker pull --disable-content-trust docker/trusttest:untrusted |
|
| 287 |
-... |
|
| 288 |
-$ docker push --disable-content-trust docker/trusttest:untrusted |
|
| 289 |
-... |
|
| 290 |
-``` |
|
| 263 |
+Because the tag `docker/trusttest:latest` is not trusted, the `pull` fails. |
|
| 291 | 264 |
|
| 292 | 265 |
## Related information |
| 293 | 266 |
|