-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- define target types and refer to them in relevant places - use consistent structure for all targets docs (also simplify it) - (also update scanner embedding doc)
- Loading branch information
Showing
11 changed files
with
301 additions
and
645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,41 @@ | ||
# Embed in Dockerfile | ||
|
||
Scan your image as part of the build process by embedding Trivy in the | ||
Dockerfile. This approach can be used to update Dockerfiles currently using | ||
Aqua’s [Microscanner][microscanner]. | ||
You can scan your image as part of the image build process by embedding Trivy in the Dockerfile. | ||
When scanning the container contents, use the [rootfs](../../target/rootfs.md) target. | ||
|
||
```bash | ||
$ cat Dockerfile | ||
FROM alpine:3.7 | ||
Examples: | ||
|
||
Using the [Trivy install script](../../../getting-started/installation.md#install-script-official): | ||
|
||
```Dockerfile | ||
FROM ... | ||
// your build steps | ||
|
||
RUN apk add curl \ | ||
&& curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin \ | ||
&& trivy rootfs --exit-code 1 --no-progress / | ||
``` | ||
|
||
$ docker build -t vulnerable-image . | ||
Using the [Trivy official image](../../../getting-started/installation.md#container-image-official) to avoid insecure `curl | sh`: | ||
|
||
```Dockerfile | ||
FROM ... | ||
// your build steps | ||
|
||
COPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy | ||
RUN trivy rootfs --exit-code 1 --no-progress / | ||
``` | ||
Alternatively you can use Trivy in a multistage build. Thus avoiding the | ||
insecure `curl | sh`. Also the image is not changed. | ||
```bash | ||
[...] | ||
# Run vulnerability scan on build image | ||
FROM build AS vulnscan | ||
|
||
Using multi-stage build to separate scanning from the build artifact: | ||
|
||
```Dockerfile | ||
FROM ... as build | ||
// your build steps | ||
|
||
FROM build as vulnscan | ||
COPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy | ||
RUN trivy rootfs --exit-code 1 --no-progress / | ||
[...] | ||
|
||
FROM build | ||
``` | ||
|
||
[microscanner]: https://github.com/aquasecurity/microscanner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.