- The container has complex external dependencies such as databases, message queues, third-party services that you cannot realistically exercise in a local ephemeral run.
- You want profiling to happen in a realistic environment, such as staging, that mirrors production traffic.
- You already have integration or end-to-end tests and want reachability to reflect those tests.
Run the container scan using the new
endorctl container scan command. The endorctl scan --container command does not support container reachability.Prerequisites
To perform instrumented container reachability analysis, ensure that:- Enable container scanning using the
--os-reachabilityflag. - Install and authenticate endorctl.
- You have installed Docker daemon
dockerdon the host and it runs and is accessible to the current user without elevated privileges. For example,docker imagesshould work withoutsudo. - The negotiated Docker API version between the client and server is
1.48or higher. - You must run the scan from either a Linux or a macOS host machine. Endor Labs supports container reachability on both amd64 and arm64 architectures.
- Docker: Docker daemon and Docker CLI is available and you can run the instrumented image locally.
- Kubernetes: You have configured
kubectlwith access to your cluster so you can deploy and run the instrumented image in a pod.
Determine instrumented container reachability using Kubernetes
Follow these steps to scan the original image, collect runtime profiling data, and determine reachability for containers using Kubernetes.-
Run
endorctl container instrumentto create a new image with a lightweight sensor injected into the filesystem. The resulting image will have-instrumentedappended to the tag.-
--image: Original container image to instrument. -
--app-stop-signal: Signal used to stop the application. The sensor needs this so it can flush profiling data before the container exits. -
--load-instrumented-image: Loads the instrumented image into your local Docker runtime so Kubernetes can reference it. -
To instrument a multi-arch image for specific platforms, run
endorctl container instrumentwith the--platformflag.
-
-
Define how the instrumented image runs in a manifest. Create a manifest file such as
demo-manifest-file.yamlto identify your workload. In the manifest, reference the instrumented image from step 1 and use a pod name and container name you can reuse later. You can also addenv,volumes, and other options as needed for your application.- Set
securityContext.privilegedtotrueso the profiling sensor can run. - Set
restartPolicytoOnFailureso that the pod does not restart automatically after you stop the app to generate the report.
- Set
-
Deploy the instrumented image to Kubernetes. The application runs normally while the sensor observes file access and process activity while the application runs.
Replace
<manifest-file>,<pod-name>, and<container-name>with the values from your manifest.-
If you need to access the application locally, run:
- You can also run your tests or interact with the application normally. The profiling sensor will capture runtime activity.
-
If you need to access the application locally, run:
-
After you finish testing, send the
--app-stop-signal, for example,QUIT, to stop the application gracefully. This signal triggers the profiling sensor to write thecreport.jsonfile and generate the profiling data. -
The sensor writes a profiling report to a known artifacts directory inside the container.
-
Verify that the
creport.jsonfile exists in the container:
-
Verify that the
-
Create a local directory and copy the report to it.
-
To verify the copy, run:
-
Alternatively, you can use
endorctl container collectto stop the running application and retrieve the profiling report from the instrumented container into a local directory. Skip steps 4, 5, and 6 if you are using this command. -
Set
--dynamic-profiling-datatotrueto collect profiling data from the instrumented container. -
Set
--output-dirto the local directory that stores the collected data. The command creates a subdirectory under this pathcluster/pod/container. Use that path for--profiling-data-dirin the next step.
-
To verify the copy, run:
-
Run
endorctl container scanwith the path to the directory that contains the collected profiling data, and OS reachability enabled. Endor Labs loads the report, maps runtime files to OS packages, and marks the corresponding packages as reachable. -
Remove the pod after completing the analysis:
-
Optionally, publish the instrumented image to a registry using the
--publishflag. The command pushes the image only if the Docker daemon is already authenticated with the target registry.endorctlwill not attempt to re-authenticate with the container registry.
Determine instrumented container reachability using Docker
Follow these steps to scan the original image, collect runtime profiling data, and determine reachability for containers using Docker.-
Run
endorctl container instrumentto create a new image with a lightweight sensor injected into the filesystem. At runtime, the sensor writescreport.jsonto/opt/_instrumented/artifacts/. By default, the command saves the image asinstrumented-image.tar. To use a different output path, pass--output-image-tar.--image: Container image you want to instrument.--app-stop-signal: Signal that stops the application so the sensor can flush profiling data before the container exits.--load-instrumented-image: Loads the instrumented image into Docker so you can run it withdocker run.
-
Run the instrumented image in Docker with
--privilegedso the sensor can useptraceto watch file access. Docker blocksptracein unprivileged containers by default. You can run tests or interact with the application while the container runs. The sensor observes file access and process activity.You can also pass:-e KEY=VALUE, for example-e PASSWORD=testpassword123, to provide environment variables your app needs to start.-p <host-port>:<container-port>, for example-p 8080:8080, to expose ports when you send traffic from your host during profiling.
-
After testing, send the
--app-stop-signalto stop the application gracefully. This signal triggers the profiling sensor to write thecreport.jsonfile. Thesleepgives the sensor time to finish writing. -
Create a local directory and copy the report to it.
-
Run
endorctl container scanwith the path to the directory that contains the collected profiling data, and OS reachability enabled. Endor Labs loads the report, maps runtime files to OS packages, and marks the corresponding packages as reachable. If you run the command outside a Git repository, pass--project-name <project-name>to avoid an initialization error. -
Remove the container after you complete the analysis.
Instrumented reachability options
You can run theendorctl container instrument command with the following options.
You can run the endorctl container collect command with the following options.
Troubleshoot issues
Why is profiling data not generated?
Why is profiling data not generated?
- Ensure that you send the QUIT signal correctly.
- Check that the container has privileged: true in security context.
-
Verify that the
--app-stop-signalmatches the signal your application handles.
Why can't Kubernetes find my instrumented image?
Why can't Kubernetes find my instrumented image?
-
Run
kind load docker-image <image>to load the image into kind. - Push the image to a container registry.
Why does my pod require privileged access?
Why does my pod require privileged access?
The profiling sensor uses
ptrace to watch file access, which unprivileged containers block by default. Set securityContext.privileged: true in the pod manifest.