Skip to content

Commit b1df0e9

Browse files
docs: update all documentation (#688)
Signed-off-by: ashnamehrotra <ashnamehrotra@gmail.com>
1 parent 9d5c9cc commit b1df0e9

File tree

1 file changed

+77
-86
lines changed

1 file changed

+77
-86
lines changed

website/docs/quick-start.md

Lines changed: 77 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Quick Start
33
---
44

5-
This sample illustrates how to patch containers using vulnerability reports with `copa`.
5+
This guide illustrates how to patch outdated containers with `copa`.
66

77
## Prerequisites
88

@@ -12,32 +12,13 @@ This sample illustrates how to patch containers using vulnerability reports with
1212
* The `docker` daemon runs a buildkit service in-process. If you are using this for your buildkit instance, Docker must have the [containerd image store feature](https://docs.docker.com/storage/containerd/) enabled.
1313
* If you are using a buildx instance, or using buildkitd directly, there is no need to enable the containerd image store. However, only images in a remote registry can be patched using these methods.
1414
* [docker](https://docs.docker.com/desktop/linux/install/#generic-installation-steps) daemon running and CLI installed & pathed.
15-
* [trivy CLI](https://aquasecurity.github.io/trivy/latest/getting-started/installation/) installed & pathed.
16-
* Alternatively, see [scanner plugins](#scanner-plugins) for custom scanner support.
15+
* Optional:
16+
* [trivy CLI](https://aquasecurity.github.io/trivy/latest/getting-started/installation/) installed & pathed.
17+
* Alternatively, see [scanner plugins](#scanner-plugins) for custom scanner support.
1718

1819
## Sample Steps
19-
Copa can patch images in two ways:
20-
- Update only vulnerable packages as detected by a supported scanner report.
21-
- Update all outdated packages in a container, regardless of vulnerability status.
2220

23-
:::note
24-
The update all functionality allows you to address discrepancies that may arise between scanners and the packages they flag as vulnerable. It is important to note, however, that some upgrades can introduce dependency or compatibility conflicts.
25-
:::
26-
27-
### Patch with scanner report:
28-
1. Scan the container image for patchable OS vulnerabilities, outputting the results to a JSON file:
29-
30-
```bash
31-
trivy image --vuln-type os --ignore-unfixed -f json -o nginx.1.21.6.json docker.io/library/nginx:1.21.6
32-
```
33-
34-
You can also see the existing patchable vulnerabilities in table form on the shell with:
35-
36-
```bash
37-
trivy image --vuln-type os --ignore-unfixed docker.io/library/nginx:1.21.6
38-
```
39-
40-
2. To patch the image, use the Trivy report and specify a buildkit instance to connect to:
21+
1. Before patching your image, specify a buildkit instance to connect to:
4122

4223
By default copa will attempt to auto-connect to an instance in order:
4324
1. Default docker buildkit endpoint (requires at least docker v24.0 with [containerd image store](https://docs.docker.com/storage/containerd/#enable-containerd-image-store-on-docker-engine) support enabled)
@@ -46,38 +27,95 @@ The update all functionality allows you to address discrepancies that may arise
4627

4728
If an instance doesn't exist or that instance doesn't support all the features copa needs the next will be attempted. Please see [custom buildkit addresses](custom-address.md) for more information.
4829

49-
After setting up the buildkit instance, run the following command to patch the image:
50-
51-
```bash
52-
copa patch -r nginx.1.21.6.json -i docker.io/library/nginx:1.21.6
53-
```
54-
55-
If you want to patch an image using the digest, run the following command instead:
56-
3.
30+
2. Scan the container image to check for patchable OS vulnerabilities:
5731
```bash
58-
copa patch -r nginx.1.21.6.json -i docker.io/library/nginx:1.21.6@sha256:25dedae0aceb6b4fe5837a0acbacc6580453717f126a095aa05a3c6fcea14dd4
32+
$ export IMAGE=docker.io/library/nginx:1.21.6
33+
$ trivy image --vuln-type os --ignore-unfixed $IMAGE
34+
nginx:1.21.6 (debian 11.3)
35+
==========================
36+
Total: 207 (UNKNOWN: 0, LOW: 12, MEDIUM: 104, HIGH: 76, CRITICAL: 15)
37+
...
5938
```
6039

61-
In any of these cases, `copa` is non-destructive and exports a new image with the specified `1.21.6-patched` label to the local Docker daemon.
40+
3. Patch the supplied image with Copa:
41+
42+
1. Update all outdated packages
43+
By default, Copa will update all outdated packages in an image to the latest available versions.
44+
:::note
45+
Upgrading all packages may introduce compatibility issues or break existing functionality. Make sure to test the patched image to ensure stability.
46+
:::
47+
48+
```bash
49+
copa patch -i $IMAGE
50+
```
51+
52+
:::tip
53+
If you want to patch an image using the digest, run the following command instead:
54+
55+
```bash
56+
export IMAGE=docker.io/library/nginx:1.21.6@sha256:25dedae0aceb6b4fe5837a0acbacc6580453717f126a095aa05a3c6fcea14dd4
57+
copa patch -i $IMAGE
58+
```
59+
:::
60+
61+
2. Update only targeted packages
62+
Alternatively, you can chose to have a targeted patching of your image by providing an optional vulnerability report. In the following commands, we are only updating packages marked vulnerable by Trivy:
63+
64+
2.1. Scan the container image for patchable OS vulnerabilities, outputting the results to a JSON file:
65+
```bash
66+
trivy image --vuln-type os --ignore-unfixed -f json -o $(basename $IMAGE).json $IMAGE
67+
```
68+
69+
2.2. Supply the Trivy report as an additional argument to the Copa command to patch image.
70+
71+
```bash
72+
copa patch -r $(basename $IMAGE).json -i $IMAGE
73+
```
74+
75+
In both cases by default, Copa will produce a tag with a `-patched` suffix and export a new image with the specified `1.21.6-patched` label to the local Docker daemon.
6276

6377
:::note
6478
If you're running this sample against an image from a private registry instead,ensure that the credentials are configured in the default Docker config.json before running `copa patch`, for example, via `docker login -u <user> -p <password> <registry>`.
6579
:::
6680
6781
:::note
68-
If you're scanning and patching an image that is local-only (i.e. built or tagged locally but not pushed to a registry), `copa` is limited to using `docker`'s built-in buildkit service, and must use the [`containerd image store`](https://docs.docker.com/storage/containerd/) feature. This is because only `docker`'s built-in buildkit service has access to the docker image store (see [Prerequisites](#prerequisites) for more information.)
82+
If you're patching an image that is local-only (i.e. built or tagged locally but not pushed to a registry), `copa` is limited to using `docker`'s built-in buildkit service, and must use the [`containerd image store`](https://docs.docker.com/storage/containerd/) feature. This is because only `docker`'s built-in buildkit service has access to the docker image store (see [Prerequisites](#prerequisites) for more information.)
6983
:::
84+
85+
4. Scan the patched image again and verify that the vulnerabilities have been patched:
7086

71-
3. Scan the patched image and verify that the vulnerabilities have been patched:
87+
```bash
88+
$ trivy image --vuln-type os --ignore-unfixed $IMAGE-patched
89+
nginx:1.21.6-patched (debian 11.10)
90+
===================================
91+
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
92+
```
93+
94+
5. Run the container to verify that the image has no regressions:
7295

7396
```bash
74-
trivy image --vuln-type os --ignore-unfixed docker.io/library/nginx:1.21.6-patched
97+
$ docker run -it --rm --name test $IMAGE-patched
98+
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
99+
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
100+
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
101+
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
102+
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
103+
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
104+
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
105+
/docker-entrypoint.sh: Configuration complete; ready for start up
106+
2024/01/22 23:32:54 [notice] 1#1: using the "epoll" event method
107+
2024/01/22 23:32:54 [notice] 1#1: nginx/1.21.6
108+
2024/01/22 23:32:54 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
109+
2024/01/22 23:32:54 [notice] 1#1: OS: Linux 6.2.0-1018-azure
110+
2024/01/22 23:32:54 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
111+
2024/01/22 23:32:54 [notice] 1#1: start worker processes
75112
```
113+
You can stop the container by opening a new shell instance and running: `docker stop test`
76114
77-
You can also inspect the structure of the patched image with `docker history` to see the new patch layer appended to the image:
115+
6. You can inspect the structure of the patched image with `docker history` to see the new patch layer appended to the image:
78116
79117
```bash
80-
$ docker history docker.io/library/nginx:1.21.6-patched
118+
$ docker history $IMAGE-patched
81119
IMAGE CREATED CREATED BY SIZE COMMENT
82120
262dacfeb193 About a minute ago mount / from exec sh -c apt install --no-ins… 41.1MB buildkit.exporter.image.v0
83121
<missing> 20 months ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B
@@ -96,50 +134,3 @@ The update all functionality allows you to address discrepancies that may arise
96134
<missing> 20 months ago /bin/sh -c #(nop) CMD ["bash"] 0B
97135
<missing> 20 months ago /bin/sh -c #(nop) ADD file:134f25aec8adf83cb… 91.8MB
98136
```
99-
100-
4. Run the container to verify that the image has no regressions:
101-
102-
```bash
103-
$ docker run -it --rm --name nginx-test docker.io/library/nginx:1.21.6-patched
104-
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
105-
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
106-
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
107-
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
108-
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
109-
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
110-
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
111-
/docker-entrypoint.sh: Configuration complete; ready for start up
112-
2024/01/22 23:32:54 [notice] 1#1: using the "epoll" event method
113-
2024/01/22 23:32:54 [notice] 1#1: nginx/1.21.6
114-
2024/01/22 23:32:54 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
115-
2024/01/22 23:32:54 [notice] 1#1: OS: Linux 6.2.0-1018-azure
116-
2024/01/22 23:32:54 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
117-
2024/01/22 23:32:54 [notice] 1#1: start worker processes
118-
```
119-
You can stop the container by opening a new shell instance and running: `docker stop nginx-test`
120-
121-
### Patch all outdated packages:
122-
1. Run Copa with a buildkit connection as described above, and omit the report flag:
123-
124-
```bash
125-
copa patch -i docker.io/library/nginx:1.21.6
126-
```
127-
2. Run the container to verify that the image has no regressions:
128-
```bash
129-
$ docker run -it --rm --name nginx-test docker.io/library/nginx:1.21.6-patched
130-
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
131-
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
132-
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
133-
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
134-
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
135-
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
136-
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
137-
/docker-entrypoint.sh: Configuration complete; ready for start up
138-
2024/01/22 23:32:54 [notice] 1#1: using the "epoll" event method
139-
2024/01/22 23:32:54 [notice] 1#1: nginx/1.21.6
140-
2024/01/22 23:32:54 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
141-
2024/01/22 23:32:54 [notice] 1#1: OS: Linux 6.2.0-1018-azure
142-
2024/01/22 23:32:54 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
143-
2024/01/22 23:32:54 [notice] 1#1: start worker processes
144-
```
145-
You can stop the container by opening a new shell instance and running: `docker stop nginx-test`

0 commit comments

Comments
 (0)