|
@@ -12,7 +12,7 @@ parent= "smn_content_trust"
|
|
|
|
|
|
This page explains how to set up and use a sandbox for experimenting with trust.
|
|
|
The sandbox allows you to configure and try trust operations locally without
|
|
|
-impacting your production images.
|
|
|
+impacting your production images.
|
|
|
|
|
|
Before working through this sandbox, you should have read through the [trust
|
|
|
overview](/security/trust/content_trust).
|
|
@@ -48,7 +48,7 @@ The sandbox uses the Docker daemon on your local system. Within the `notarysandb
|
|
|
you interact with a local registry rather than the Docker Hub. This means
|
|
|
your everyday image repositories are not used. They are protected while you play.
|
|
|
|
|
|
-When you play in the sandbox, you'll also create root and tagging keys. The
|
|
|
+When you play in the sandbox, you'll also create root and repository keys. The
|
|
|
sandbox is configured to store all the keys and files inside the `notarysandbox`
|
|
|
container. Since the keys you create in the sandbox are for play only,
|
|
|
destroying the container destroys them as well.
|
|
@@ -68,9 +68,9 @@ client inside the `notarysandbox` container connects to them over your network.
|
|
|
So, you'll need an entry for both the servers in your local `/etc/hosts` file.
|
|
|
|
|
|
1. Add an entry for the `notaryserver` to `/etc/hosts`.
|
|
|
-
|
|
|
+
|
|
|
$ sudo sh -c 'echo "127.0.0.1 notaryserver" >> /etc/hosts'
|
|
|
-
|
|
|
+
|
|
|
2. Add an entry for the `sandboxregistry` to `/etc/hosts`.
|
|
|
|
|
|
$ sudo sh -c 'echo "127.0.0.1 sandboxregistry" >> /etc/hosts'
|
|
@@ -113,7 +113,7 @@ So, you'll need an entry for both the servers in your local `/etc/hosts` file.
|
|
|
RUN update-ca-certificates
|
|
|
|
|
|
ENTRYPOINT ["bash"]
|
|
|
-
|
|
|
+
|
|
|
6. Save and close the file.
|
|
|
|
|
|
7. Build the testing container.
|
|
@@ -123,7 +123,7 @@ So, you'll need an entry for both the servers in your local `/etc/hosts` file.
|
|
|
Step 1 : FROM debian:jessie
|
|
|
...
|
|
|
Successfully built 5683f17e9d72
|
|
|
-
|
|
|
+
|
|
|
|
|
|
### Build and start up the trust servers
|
|
|
|
|
@@ -137,7 +137,7 @@ Then, you'll use Docker Compose to build and start them on your local system.
|
|
|
2. Clone the `notary` project.
|
|
|
|
|
|
$ git clone -b trust-sandbox https://github.com/docker/notary.git
|
|
|
-
|
|
|
+
|
|
|
3. Clone the `distribution` project.
|
|
|
|
|
|
$ git clone https://github.com/docker/distribution.git
|
|
@@ -152,31 +152,31 @@ Then, you'll use Docker Compose to build and start them on your local system.
|
|
|
|
|
|
5. Build the server images.
|
|
|
|
|
|
- $ docker-compose build
|
|
|
-
|
|
|
+ $ docker-compose build
|
|
|
+
|
|
|
The first time you run this, the build takes some time.
|
|
|
-
|
|
|
+
|
|
|
6. Run the server containers on your local system.
|
|
|
|
|
|
$ docker-compose up -d
|
|
|
|
|
|
Once the trust services are up, you'll setup a local version of the Docker
|
|
|
- Registry v2.
|
|
|
-
|
|
|
+ Registry v2.
|
|
|
+
|
|
|
7. Change to the `notarysandbox/distribution` directory.
|
|
|
|
|
|
8. Build the `sandboxregistry` server.
|
|
|
|
|
|
$ docker build -t sandboxregistry .
|
|
|
|
|
|
-9. Start the `sandboxregistry` server running.
|
|
|
-
|
|
|
+9. Start the `sandboxregistry` server running.
|
|
|
+
|
|
|
$ docker run -p 5000:5000 --name sandboxregistry sandboxregistry &
|
|
|
|
|
|
## Playing in the sandbox
|
|
|
|
|
|
Now that everything is setup, you can go into your `notarysandbox` container and
|
|
|
-start testing Docker content trust.
|
|
|
+start testing Docker content trust.
|
|
|
|
|
|
|
|
|
### Start the notarysandbox container
|
|
@@ -187,7 +187,7 @@ communication among the containers.
|
|
|
|
|
|
```
|
|
|
$ docker run -it -v /var/run/docker.sock:/var/run/docker.sock --link notary_notaryserver_1:notaryserver --link sandboxregistry:sandboxregistry notarysandbox
|
|
|
-root@0710762bb59a:/#
|
|
|
+root@0710762bb59a:/#
|
|
|
```
|
|
|
|
|
|
Mounting the `docker.sock` gives the `notarysandbox` access to the `docker`
|
|
@@ -196,28 +196,28 @@ container. When you destroy the container, you destroy the "play" keys.
|
|
|
|
|
|
### Test some trust operations
|
|
|
|
|
|
-Now, you'll pull some images.
|
|
|
+Now, you'll pull some images.
|
|
|
|
|
|
1. Download a `docker` image to test with.
|
|
|
|
|
|
- # docker pull docker/trusttest
|
|
|
+ # docker pull docker/trusttest
|
|
|
docker pull docker/trusttest
|
|
|
Using default tag: latest
|
|
|
latest: Pulling from docker/trusttest
|
|
|
|
|
|
- b3dbab3810fc: Pull complete
|
|
|
- a9539b34a6ab: Pull complete
|
|
|
+ b3dbab3810fc: Pull complete
|
|
|
+ a9539b34a6ab: Pull complete
|
|
|
Digest: sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a
|
|
|
Status: Downloaded newer image for docker/trusttest:latest
|
|
|
|
|
|
-2. Tag it to be pushed to our sandbox registry:
|
|
|
+2. Tag it to be pushed to our sandbox registry:
|
|
|
|
|
|
# docker tag docker/trusttest sandboxregistry:5000/test/trusttest:latest
|
|
|
|
|
|
3. Enable content trust.
|
|
|
|
|
|
# export DOCKER_CONTENT_TRUST=1
|
|
|
-
|
|
|
+
|
|
|
4. Identify the trust server.
|
|
|
|
|
|
# export DOCKER_CONTENT_TRUST_SERVER=https://notaryserver:4443
|
|
@@ -237,8 +237,8 @@ Now, you'll pull some images.
|
|
|
|
|
|
# docker push sandboxregistry:5000/test/trusttest:latest
|
|
|
The push refers to a repository [sandboxregistry:5000/test/trusttest] (len: 1)
|
|
|
- a9539b34a6ab: Image successfully pushed
|
|
|
- b3dbab3810fc: Image successfully pushed
|
|
|
+ a9539b34a6ab: Image successfully pushed
|
|
|
+ b3dbab3810fc: Image successfully pushed
|
|
|
latest: digest: sha256:1d871dcb16805f0604f10d31260e79c22070b35abc71a3d1e7ee54f1042c8c7c size: 3348
|
|
|
Signing and pushing trust metadata
|
|
|
You are about to create a new root signing key passphrase. This passphrase
|
|
@@ -247,22 +247,22 @@ Now, you'll pull some images.
|
|
|
key file itself secure and backed up. It is highly recommended that you use a
|
|
|
password manager to generate the passphrase and keep it safe. There will be no
|
|
|
way to recover this key. You can find the key in your config directory.
|
|
|
- Enter passphrase for new offline key with id 8c69e04:
|
|
|
- Repeat passphrase for new offline key with id 8c69e04:
|
|
|
- Enter passphrase for new tagging key with id sandboxregistry:5000/test/trusttest (93c362a):
|
|
|
- Repeat passphrase for new tagging key with id sandboxregistry:5000/test/trusttest (93c362a):
|
|
|
+ Enter passphrase for new root key with id 8c69e04:
|
|
|
+ Repeat passphrase for new root key with id 8c69e04:
|
|
|
+ Enter passphrase for new repository key with id sandboxregistry:5000/test/trusttest (93c362a):
|
|
|
+ Repeat passphrase for new repository key with id sandboxregistry:5000/test/trusttest (93c362a):
|
|
|
Finished initializing "sandboxregistry:5000/test/trusttest"
|
|
|
latest: digest: sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a size: 3355
|
|
|
Signing and pushing trust metadata
|
|
|
|
|
|
7. Try pulling the image you just pushed:
|
|
|
|
|
|
- # docker pull sandboxregistry:5000/test/trusttest
|
|
|
+ # docker pull sandboxregistry:5000/test/trusttest
|
|
|
Using default tag: latest
|
|
|
Pull (1 of 1): sandboxregistry:5000/test/trusttest:latest@sha256:1d871dcb16805f0604f10d31260e79c22070b35abc71a3d1e7ee54f1042c8c7c
|
|
|
sha256:1d871dcb16805f0604f10d31260e79c22070b35abc71a3d1e7ee54f1042c8c7c: Pulling from test/trusttest
|
|
|
- b3dbab3810fc: Already exists
|
|
|
- a9539b34a6ab: Already exists
|
|
|
+ b3dbab3810fc: Already exists
|
|
|
+ a9539b34a6ab: Already exists
|
|
|
Digest: sha256:1d871dcb16805f0604f10d31260e79c22070b35abc71a3d1e7ee54f1042c8c7c
|
|
|
Status: Downloaded newer image for sandboxregistry:5000/test/trusttest@sha256:1d871dcb16805f0604f10d31260e79c22070b35abc71a3d1e7ee54f1042c8c7c
|
|
|
Tagging sandboxregistry:5000/test/trusttest@sha256:1d871dcb16805f0604f10d31260e79c22070b35abc71a3d1e7ee54f1042c8c7c as sandboxregistry:5000/test/trusttest:latest
|
|
@@ -281,7 +281,7 @@ data. Then, you try and pull it.
|
|
|
$ docker exec -it sandboxregistry bash
|
|
|
296db6068327#
|
|
|
|
|
|
-3. Change into the registry storage.
|
|
|
+3. Change into the registry storage.
|
|
|
|
|
|
You'll need to provide the `sha` you received when you pushed the image.
|
|
|
|
|
@@ -314,8 +314,8 @@ data. Then, you try and pull it.
|
|
|
# docker pull sandboxregistry:5000/test/trusttest
|
|
|
Using default tag: latest
|
|
|
...
|
|
|
- b3dbab3810fc: Verifying Checksum
|
|
|
- a9539b34a6ab: Pulling fs layer
|
|
|
+ b3dbab3810fc: Verifying Checksum
|
|
|
+ a9539b34a6ab: Pulling fs layer
|
|
|
filesystem layer verification failed for digest sha256:aac0c133338db2b18ff054943cee3267fe50c75cdee969aed88b1992539ed042
|
|
|
|
|
|
You'll see the the pull did not complete because the trust system was
|