-
Notifications
You must be signed in to change notification settings - Fork 7.8k
dhi: add customizations #23035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
dhi: add customizations #23035
Changes from 1 commit
5ee2eb4
e88c1a9
f3e1891
c4f8a1e
ef05d2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--- | ||
title: Customize a Docker Hardened Image | ||
linkTitle: Customize an image | ||
weight: 25 | ||
keywords: debug, hardened images, DHI, customize, certificate, artififact | ||
Check failure on line 5 in content/manuals/dhi/how-to/customize.md
|
||
description: Learn how to customize a Docker Hardened Images (DHI). | ||
--- | ||
|
||
You can customize a Docker Hardened Image (DHI) to suit your specific needs | ||
using the Docker Hub UI. This allows you to select a base image, add packages, | ||
add artifacts, and configure settings. In addition, the build pipeline ensures that | ||
your customized image is built securely and includes attestations. | ||
|
||
To add a customized Docker Hardened Image to your organization, you must first | ||
[mirror](./mirror.md) the DHI repository to your organization. | ||
|
||
## Customize a Docker Hardened Image | ||
|
||
To customize a Docker Hardened Image, follow these steps: | ||
|
||
1. Sign in to [Docker Hub](https://hub.docker.com). | ||
2. Select **My Hub**. | ||
3. In the namespace drop-down, select your organization that has a mirrored DHI | ||
repository. | ||
4. Select the mirrored DHI repository. | ||
5. Select the **Customizations** tab. | ||
6. Select **Create customization**. | ||
|
||
At this point, the on-screen instructions will guide you through the | ||
customization process. You can continue with the following steps for more | ||
details. | ||
|
||
7. Select the image version you want to customize. | ||
8. Add packages. | ||
|
||
1. In the **Packages** drop-down, select the packages you want to add to the | ||
craig-osterhout marked this conversation as resolved.
Show resolved
Hide resolved
|
||
image. | ||
2. In the **OCI artifacts** drop-down select the OCI artifacts you want to | ||
add to the image. The OCI artifacts are images that you have previously | ||
built and pushed to a repository in the same namespace as the mirrored | ||
DHI. For example, you can add a custom root CA certificate or a another | ||
Check warning on line 41 in content/manuals/dhi/how-to/customize.md
|
||
image that contains a tool you need, like adding Python to a Node.js | ||
image. For more details on how to create an OCI artifact image, see | ||
[Create an OCI artifact image](#create-an-oci-artifact-image). | ||
|
||
When combining images that contain directories and files with the same | ||
path, images later in the list will overwrite files from earlier images. | ||
To manage this, you can further select paths to include or exclude from | ||
each OCI artifact image. This allows you to control which files are | ||
included in the final customized image. | ||
|
||
> [!NOTE] | ||
> | ||
> When necessary files are overwritten, the image build still | ||
> succeeds, but you may have issues when running the image. | ||
|
||
9. Select **Next: Configure** and then configure the following options. | ||
|
||
1. Specify a suffix that is appended to the customized image's tag. For | ||
example, if you specify `custom` when customizing the `dhi-python:3.13` | ||
image, the customized image will be tagged as `dhi-python:3.13_custom`. | ||
2. Select the platforms you want to build the image for. | ||
3. Add [`ENTRYPOINT`](/reference/dockerfile/#entrypoint) and | ||
[`CMD`](/reference/dockerfile/#cmd) arguments to the image. These | ||
arguments are appended to the base image's entrypoint and command. | ||
4. Specify the users to add to the image. | ||
5. Specify the user groups to add to the image. | ||
6. Select which [user](/reference/dockerfile/#user) to run the images as. | ||
7. Specify the [environment variables](/reference/dockerfile/#env) and their | ||
values that the image will contain. | ||
8. Add [annotations](/build/metadata/annotations/) to the image. | ||
9. Add [labels](/reference/dockerfile/#label) to the image. | ||
10. Select **Create Customization**. | ||
|
||
A summary of the customization appears. It may take some time for the image | ||
to build. Once built, it will appear in the **Tags** tab of the repository, | ||
and your team members can pull it like any other image. | ||
|
||
## Edit or delete a Docker Hardened Image customization | ||
|
||
To edit or delete a Docker Hardened Image customization, follow these steps: | ||
|
||
1. Sign in to [Docker Hub](https://hub.docker.com). | ||
2. Select **My Hub**. | ||
3. In the namespace drop-down, select your organization that has a mirrored DHI. | ||
4. Select the mirrored DHI repository. | ||
5. Select the **Customizations** tab. | ||
6. Select **Edit** to edit the customization, or select the trashcan icon to | ||
delete the customization. | ||
7. Follow the on-screen instructions to complete the edit or deletion. | ||
|
||
## Create an OCI artifact image | ||
|
||
An OCI artifact image is a Docker image that contains files or directories that | ||
you want to include in your customized Docker Hardened Image (DHI). This can | ||
include additional tools, libraries, or configuration files. | ||
|
||
When creating an image to use as an OCI artifact, it should ideally be as | ||
minimal as possible and contain only the necessary files. | ||
|
||
For example, to distribute a custom root CA certificate as part of a trusted CA | ||
Check warning on line 101 in content/manuals/dhi/how-to/customize.md
|
||
bundle, you can use a multi-stage build. This approach registers your | ||
certificate with the system and outputs an updated CA bundle, which can be | ||
Check warning on line 103 in content/manuals/dhi/how-to/customize.md
|
||
extracted into a minimal final image: | ||
|
||
```dockerfile | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM yourorg/dhi-bash:5-dev AS certs | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN mkdir -p /usr/local/share/ca-certificates/my-rootca | ||
COPY certs/rootCA.crt /usr/local/share/ca-certificates/my-rootca | ||
|
||
RUN update-ca-certificates | ||
|
||
FROM scratch | ||
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
``` | ||
|
||
You can follow this pattern to create other OCI artifacts, such as images | ||
containing tools or libraries that you want to include in your customized DHI. | ||
Install the necessary tools or libraries in the first stage, and then copy the | ||
relevant files to the final stage that uses `FROM scratch`. This ensures that | ||
your OCI artifact is minimal and contains only the necessary files. | ||
|
||
Build and push the OCI artifact image to a repository in your organization's | ||
namespace and it automatically appears in the customization workflow when you | ||
select the OCI artifacts to add to your customized Docker Hardened Image. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to add in some screenshots here? The UI was deployed to production yesterday, so these will be available now.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the customization UI itself is intuitive/well-guided and screenshots probably won't add much for comprehension.
The only things I can think to use screenshots for are:
@Bkblodget, are any of those the purpose you had in mind, or something else?