dhi.io/jenkins-agent
Jenkins Agent is a base image for Docker that includes Java and the Jenkins agent executable (agent.jar). This executable is an instance of the Jenkins Remoting library and enables distributed build capabilities for Jenkins controllers.
All examples in this guide use the public image. If you've mirrored the repository for your own use (for example, to your Docker Hub namespace), update your commands to reference the mirrored image instead of the public one.
For example:
dhi.io/jenkins-agent:<tag><your-namespace>/dhi-jenkins-agent:<tag>For the examples, you must first use docker login dhi.io to authenticate to the registry to pull the images.
This Docker Hardened jenkins-agent image includes the Jenkins Agent component in a single, security-hardened package:
agent.jar): Connects Jenkins agents to Jenkins controllers, located at
/usr/share/jenkins/agent.jar (Remoting version 3345)slave.jar → agent.jar at /usr/share/jenkins/slave.jar/usr/bin/java (openjdk 21.0.10, Temurin-21.0.10+7)/home/jenkins/agentNote: Unlike most Docker Hardened Images, the jenkins-agent runtime image includes bash. This is intentional — Jenkins build jobs require a shell to execute pipeline steps.
The jenkins-agent image is designed to connect to a Jenkins controller. The default CMD runs
/usr/bin/java -jar /usr/share/jenkins/agent.jar automatically, so you can start the container without specifying a
command.
docker run -i --rm --name jenkins-agent --init \
dhi.io/jenkins-agent:<tag>
This command:
-i) — required for the remoting protocol--rm)--init for proper signal handlingExpected behavior: Without a Jenkins controller connected, the agent outputs the remoting capacity handshake string and waits for input on stdin:
<===[JENKINS REMOTING CAPACITY]===>rO0ABXNyABpodWRzb24...
This is expected — the agent JAR is working correctly but waiting for a controller connection. This is not an error.
Starting from Remoting 3.8, agents support work directories which provide logging by default and change JAR caching behavior:
docker run -i --rm --name jenkins-agent --init \
-v agent-workdir:/home/jenkins/agent \
dhi.io/jenkins-agent:<tag> \
/usr/bin/java -jar /usr/share/jenkins/agent.jar -workDir /home/jenkins/agent
Expected output:
INFO: Using /home/jenkins/agent/remoting as a remoting work directory
INFO: Both error and output logs will be printed to /home/jenkins/agent/remoting
<===[JENKINS REMOTING CAPACITY]===>rO0ABXNyABpodWRzb24...
| Variable | Description | Default |
|---|---|---|
AGENT_WORKDIR | Agent work directory path | /home/jenkins/agent |
JAVA_HOME | Java installation directory | /usr/lib/jvm/temurin-21 |
JAVA_VERSION | Java version | jre-21.0.10+7 |
LANG | Locale setting | en_US.UTF-8 |
TZ | Timezone | Etc/UTC |
USER | User running the agent | jenkins |
Example with custom environment variables:
docker run -i --rm --name jenkins-agent --init \
-e TZ=America/New_York \
-e AGENT_WORKDIR=/home/jenkins/agent \
dhi.io/jenkins-agent:<tag> \
/usr/bin/java -jar /usr/share/jenkins/agent.jar -workDir /home/jenkins/agent
Connect an agent to a Jenkins controller using the URL, secret, and agent name provided by the controller:
docker run -i --rm --name jenkins-agent --init \
dhi.io/jenkins-agent:<tag> \
/usr/bin/java -jar /usr/share/jenkins/agent.jar \
-url http://jenkins-controller:8080 \
-workDir /home/jenkins/agent \
-secret <secret> \
-name <agent-name>
Use a named volume to persist the agent work directory across container restarts:
docker run -i --rm --name jenkins-agent --init \
-v jenkins-agent-work:/home/jenkins/agent \
dhi.io/jenkins-agent:<tag> \
/usr/bin/java -jar /usr/share/jenkins/agent.jar -workDir /home/jenkins/agent
Deploy Jenkins agents in Kubernetes using a Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins-agent
spec:
replicas: 1
selector:
matchLabels:
app: jenkins-agent
template:
metadata:
labels:
app: jenkins-agent
spec:
containers:
- name: jenkins-agent
image: dhi.io/jenkins-agent:<tag>
command: ["/usr/bin/java", "-jar", "/usr/share/jenkins/agent.jar"]
args: ["-workDir", "/home/jenkins/agent"]
volumeMounts:
- name: agent-work
mountPath: /home/jenkins/agent
env:
- name: AGENT_WORKDIR
value: "/home/jenkins/agent"
volumes:
- name: agent-work
emptyDir: {}
Configure JVM options for the agent:
docker run -i --rm --name jenkins-agent --init \
dhi.io/jenkins-agent:<tag> \
/usr/bin/java -Xmx512m -Xms256m \
-jar /usr/share/jenkins/agent.jar -workDir /home/jenkins/agent
| Feature | DOI (docker.io/jenkins/agent) | DHI (dhi.io/jenkins-agent) |
|---|---|---|
| User | jenkins | jenkins |
| Shell | bash (included) | bash (included) |
| Package manager | Included | No (runtime) / APT (dev) |
| Default CMD | ["bash"] | ["/usr/bin/java","-jar","/usr/share/jenkins/agent.jar"] |
| Entrypoint | None | None |
| Java version | OpenJDK 21 (Temurin) | OpenJDK 21.0.10 (Temurin-21.0.10+7) |
JAVA_HOME | /opt/java/openjdk | /usr/lib/jvm/temurin-21 |
LANG | C.UTF-8 | en_US.UTF-8 |
| Remoting version | 3307 | 3345 (newer) |
| Zero CVE commitment | No | Yes |
| FIPS variant | No | Yes (subscription required) |
| Base OS | Debian | Docker Hardened Images (Debian 13) |
| Signed provenance | No | Yes |
| SBOM / VEX metadata | No | Yes |
| Compliance labels | None | CIS (runtime) |
| Architectures | amd64, arm64 | amd64, arm64 |
Docker Hardened Images come in different variants depending on their intended use. Image variants are identified by their tag.
Runtime variants are designed to run the Jenkins agent in production. These images:
jenkins userBuild-time variants typically include dev in the tag name and are intended for use in the first stage of a
multi-stage Dockerfile. These images typically:
FIPS variants include fips in the variant name and tag. They use cryptographic modules validated under FIPS 140,
a U.S. government standard for secure cryptographic operations. Pulling FIPS variants requires a Docker subscription —
the tags return 401 without one.
To view the image variants and get more information about them, select the Tags tab for this repository, and then select a tag.
To migrate your application to a Docker Hardened Image, update your Dockerfile or Kubernetes manifests. Common changes are listed in the following table of migration notes.
| Item | Migration note |
|---|---|
| Base image | Replace your base images in your Dockerfile or Kubernetes manifests with a Docker Hardened Image. |
| Package management | Runtime images don't contain package managers. Use images with a dev tag for build stages that require package installation. |
| User | Both DOI and DHI run as the jenkins user. No changes required. |
| Shell | The runtime image includes bash. No changes required for build jobs that rely on a shell. |
| Default CMD | DOI defaults to ["bash"]. DHI defaults to ["/usr/bin/java","-jar","/usr/share/jenkins/agent.jar"]. Update any scripts that rely on the DOI default CMD. |
| Java path | DOI JAVA_HOME=/opt/java/openjdk. DHI JAVA_HOME=/usr/lib/jvm/temurin-21. Update any scripts that reference JAVA_HOME directly. |
| TLS certificates | Docker Hardened Images contain standard TLS certificates by default. There is no need to install TLS certificates. |
| Ports | Jenkins agents do not bind to any ports — they make outbound connections to the controller only. Privileged port restrictions do not apply. |
| agent.jar path | Both DOI and DHI use /usr/share/jenkins/agent.jar. No changes required. |
| Multi-stage build | Utilize images with a dev tag for build stages and runtime images for production. |
The following steps outline the general migration process.
Find hardened images for your app. Inspect the image tags for dhi.io/jenkins-agent and find the variant that
meets your needs (runtime, dev, or FIPS).
Update the image reference in your Kubernetes manifests or Dockerfile.
# In your Deployment manifest
containers:
- name: jenkins-agent
image: dhi.io/jenkins-agent:<tag>
Update the default CMD if needed. The DHI default CMD runs the agent jar directly. If your existing setup
overrides the CMD, verify the java path is /usr/bin/java.
Verify the agent connects to the controller. After migration, confirm the agent appears as online in the Jenkins controller UI.
Use Docker Debug to attach to a running container for debugging:
docker debug <container-name>
The runtime image runs as the jenkins user. Ensure that mounted volumes and files are accessible to the jenkins
user. You may need to set appropriate permissions on host directories before mounting them.
Passing the secret and agent name as positional arguments is deprecated and produces a warning:
WARNING: Providing the secret and agent name as positional arguments is deprecated;
use "-secret" and "-name" instead.
Always use the -secret and -name flags explicitly:
/usr/bin/java -jar /usr/share/jenkins/agent.jar \
-url http://jenkins-controller:8080 \
-secret <secret> \
-name <agent-name>
The DOI default CMD is ["bash"] while the DHI default CMD is
["/usr/bin/java","-jar","/usr/share/jenkins/agent.jar"]. If your setup relies on the DOI default, update your
command or args fields in Kubernetes manifests or your docker run command accordingly.
The DHI JAVA_HOME is /usr/lib/jvm/temurin-21 while the DOI JAVA_HOME is /opt/java/openjdk. Update any scripts or
environment variables that reference JAVA_HOME directly.
The runtime image does not include a package manager. If your build jobs require additional tools, use the dev image
variant as a build stage and copy the required binaries to the runtime stage.
Docker Hardened Images may have different entry points than images such as Docker Official Images. Use docker inspect
to inspect entry points for Docker Hardened Images and update your Dockerfile if necessary.