dhi.io/jenkins-inbound-agent
Jenkins Inbound Agent is a specialized Docker image for Kubernetes and containerized environments. It automatically connects to a Jenkins controller using environment variables, making it ideal for dynamic agent provisioning in Kubernetes clusters and CI/CD pipelines.
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/<repository>:<tag><your-namespace>/dhi-<repository>:<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 Inbound Agent image includes:
/opt/java/openjdk/21-jre for running the agent/home/jenkins/agent/usr/local/bin/jenkins-agent) that automatically starts the agent using environment variablesNote: The Jenkins Inbound Agent image is designed to run as-is and connect to a Jenkins controller. Extending this image is uncommon — most customization is handled through environment variables. Use the
devvariant if you need a shell or package manager for build stages.
The Jenkins Inbound Agent image automatically connects to a Jenkins controller using environment variables. The entrypoint script reads configuration from environment variables and starts the agent without requiring manual command-line arguments.
To start a Jenkins inbound agent container, run the following command:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
dhi.io/jenkins-inbound-agent:3345-debian13
This command:
-d)--init for proper signal handling and subprocess managementagent.jar with the correct parametersNote: The JENKINS_SECRET and JENKINS_AGENT_NAME values must match what is configured in your Jenkins controller.
You can find these values in the Jenkins UI when creating a new agent node.
Deprecation notice: Providing the secret and agent name as positional arguments is deprecated. Always use the
-secretand-nameflags, or configure them via environment variables as shown above.
Starting from Remoting 3.8, agents support work directories which provide logging by default and change JAR caching behavior:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
-e JENKINS_AGENT_WORKDIR=/home/jenkins/agent \
-v agent-workdir:/home/jenkins/agent \
dhi.io/jenkins-inbound-agent:3345-debian13
Jenkins Inbound Agent supports configuration through environment variables:
| Variable | Description | Default | Required |
|---|---|---|---|
JENKINS_URL | URL of the Jenkins controller | (empty) | Yes |
JENKINS_SECRET | Secret token from the Jenkins controller | (empty) | Yes |
JENKINS_AGENT_NAME | Name of the agent (must match controller configuration) | (empty) | Yes |
JENKINS_AGENT_WORKDIR | Agent work directory path | /home/jenkins/agent | No |
AGENT_WORKDIR | Agent work directory path (alternative to JENKINS_AGENT_WORKDIR) | /home/jenkins/agent | No |
JAVA_HOME | Java installation directory | /opt/java/openjdk/21-jre | No |
JAVA_OPTS | Additional JVM options | (empty) | No |
JENKINS_JAVA_OPTS | Java options specifically for the remoting process | (empty) | No |
REMOTING_OPTS | Additional CLI options to pass to agent.jar | (empty) | No |
JENKINS_WEB_SOCKET | Set to true to use WebSocket instead of TCP port | (empty) | No |
JENKINS_DIRECT_CONNECTION | Connect directly to TCP agent port (e.g. myjenkins:50000), skipping HTTP(S) | (empty) | No |
JENKINS_INSTANCE_IDENTITY | Base64-encoded instance identity of the Jenkins controller. When set, skips HTTP(S) for connection info. | (empty) | No |
JENKINS_PROTOCOLS | Whitelist of remoting protocols to attempt (used with JENKINS_INSTANCE_IDENTITY) | (empty) | No |
USER | User running the agent | jenkins | No |
TZ | Timezone | Etc/UTC | No |
LANG | Locale setting | en_US.UTF-8 | No |
Example with custom environment variables:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
-e JENKINS_AGENT_WORKDIR=/home/jenkins/agent \
-e TZ=America/New_York \
-e JAVA_OPTS="-Xmx512m -Xms256m" \
-v agent-workdir:/home/jenkins/agent \
dhi.io/jenkins-inbound-agent:3345-debian13
Connect an inbound agent to a Jenkins controller using environment variables:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
dhi.io/jenkins-inbound-agent:3345-debian13
Use a named volume to persist the agent work directory across container restarts:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
-e JENKINS_AGENT_WORKDIR=/home/jenkins/agent \
-v jenkins-agent-work:/home/jenkins/agent \
dhi.io/jenkins-inbound-agent:3345-debian13
Use WebSocket instead of the TCP port (port 50000) to connect to the Jenkins controller. This is useful when firewall rules block direct TCP connections:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
-e JENKINS_WEB_SOCKET=true \
dhi.io/jenkins-inbound-agent:3345-debian13
Deploy Jenkins inbound agents in Kubernetes using a Deployment. The following example shows a basic Kubernetes deployment that automatically connects to a Jenkins controller.
First, store the agent secret in a Kubernetes Secret:
kubectl create secret generic jenkins-agent-secret \
--from-literal=secret=<secret-from-controller>
Then apply the following Deployment manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins-inbound-agent
namespace: default
labels:
app: jenkins-inbound-agent
spec:
replicas: 1
selector:
matchLabels:
app: jenkins-inbound-agent
template:
metadata:
labels:
app: jenkins-inbound-agent
spec:
containers:
- name: jenkins-inbound-agent
image: dhi.io/jenkins-inbound-agent:3345-debian13
securityContext:
runAsNonRoot: true
runAsUser: 1000
allowPrivilegeEscalation: false
env:
- name: JENKINS_URL
value: "http://jenkins-controller:8080"
- name: JENKINS_SECRET
valueFrom:
secretKeyRef:
name: jenkins-agent-secret
key: secret
- name: JENKINS_AGENT_NAME
value: "k8s-agent-1"
- name: JENKINS_AGENT_WORKDIR
value: "/home/jenkins/agent"
resources:
requests:
cpu: "500m"
memory: "256Mi"
limits:
cpu: "1"
memory: "512Mi"
volumeMounts:
- name: agent-work
mountPath: /home/jenkins/agent
volumes:
- name: agent-work
emptyDir: {}
Note: When running the Kubernetes agent on Docker Desktop and connecting to a Jenkins controller running outside the
cluster (for example, in Docker Compose), use http://host.docker.internal:8080 as the JENKINS_URL instead of
http://jenkins-controller:8080.
Use Docker Compose to run a Jenkins controller with an inbound agent. Save the agent secret to a .env file before
starting:
echo "JENKINS_SECRET=<secret-from-controller>" > .env
Note: Use compose.yaml as the filename. Docker Compose will warn if both compose.yaml and docker-compose.yaml
are present in the same directory and will prefer compose.yaml.
services:
jenkins-controller:
image: dhi.io/jenkins:2.534-debian13
container_name: jenkins-controller
ports:
- "8080:8080"
- "50000:50000"
volumes:
- jenkins-data:/var/jenkins_home
networks:
- jenkins-network
healthcheck:
test: ["CMD", "java", "-jar", "/usr/share/jenkins/jenkins.war", "--version"]
interval: 30s
timeout: 10s
retries: 5
start_period: 90s
jenkins-inbound-agent:
image: dhi.io/jenkins-inbound-agent:3345-debian13
container_name: jenkins-inbound-agent
init: true
environment:
- JENKINS_URL=http://jenkins-controller:8080
- JENKINS_SECRET=${JENKINS_SECRET}
- JENKINS_AGENT_NAME=agent1
- JENKINS_AGENT_WORKDIR=/home/jenkins/agent
volumes:
- agent-work:/home/jenkins/agent
depends_on:
jenkins-controller:
condition: service_healthy
networks:
- jenkins-network
volumes:
jenkins-data:
agent-work:
networks:
jenkins-network:
Note: The DHI Jenkins controller runtime image does not include curl or wget. The healthcheck uses java
directly, which is guaranteed to be present in the image.
Configure JVM options for the agent:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
-e JAVA_OPTS="-Xmx1024m -Xms512m" \
dhi.io/jenkins-inbound-agent:3345-debian13
Docker Hardened Images come in different variants depending on their intended use. The following variants are available for this image:
| Tag | Alias | Base OS | User | Compliance | Purpose |
|---|---|---|---|---|---|
3345-debian13 | 3345 | Debian 13 | jenkins (1000) | CIS | Production runtime |
3345-debian13-dev | 3345-dev | Debian 13 | root | CIS | Build/CI stages |
3345-debian13-fips | 3345-fips | Debian 13 | jenkins (1000) | CIS, FIPS, STIG | FIPS-compliant runtime |
3345-debian13-fips-dev | 3345-fips-dev | Debian 13 | root | CIS, FIPS, STIG | FIPS-compliant build |
Note: FIPS and STIG variants (
*-fips,*-fips-dev) require a Docker subscription. Start a 30-day free trial at dhi.io to access them.
Runtime variants are designed to run your application in production. These images are intended to be used either directly or as the FROM image in the final stage of a multi-stage build. These images typically:
jenkins, UID 1000)curl, wget, or a package managerBuild-time variants 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 tag name and come in both runtime and build-time variants. They use cryptographic
modules validated under FIPS 140, a U.S. government standard for secure cryptographic operations. Both FIPS variants for
this image are also STIG-compliant at 100%, making them suitable for government and regulated industry deployments.
To use the FIPS-compliant runtime agent:
$ docker run -d --name jenkins-inbound-agent --init \
-e JENKINS_URL=http://jenkins-controller:8080 \
-e JENKINS_SECRET=<secret-from-controller> \
-e JENKINS_AGENT_NAME=agent1 \
dhi.io/jenkins-inbound-agent:3345-debian13-fips
To view all available tags, select the Tags tab for this repository in the DHI registry.
Note: The Jenkins Inbound Agent image is designed to run as-is. Extending it with a custom Dockerfile is uncommon — most customization is handled through environment variables. If you need to build on top of this image, use the
devvariant as your base.
To migrate your application to a Docker Hardened Image, you must update your Dockerfile. At minimum, you must update the base image in your existing Dockerfile to a Docker Hardened Image. This and a few other common changes are listed in the following table of migration notes.
| Item | Migration note |
|---|---|
| Base image | Replace your base images in your Dockerfile with a Docker Hardened Image. |
| Package management | Non-dev images, intended for runtime, don't contain package managers. Use package managers only in images with a dev tag. |
| Non-root user | By default, non-dev images, intended for runtime, run as the nonroot user. Ensure that necessary files and directories are accessible to the nonroot user. |
| Multi-stage build | Utilize images with a dev tag for build stages and non-dev images for runtime. For binary executables, use a static image for runtime. |
| TLS certificates | Docker Hardened Images contain standard TLS certificates by default. There is no need to install TLS certificates. |
| Ports | Non-dev hardened images run as a nonroot user by default. As a result, applications in these images can't bind to privileged ports (below 1024) when running in Kubernetes or in Docker Engine versions older than 20.10. To avoid issues, configure your application to listen on port 1025 or higher inside the container. |
| Entry point | Docker Hardened Images may have different entry points than images such as Docker Official Images. Inspect entry points for Docker Hardened Images and update your Dockerfile if necessary. |
| No shell | By default, non-dev images, intended for runtime, don't contain a shell. Use dev images in build stages to run shell commands and then copy artifacts to the runtime stage. |
The following steps outline the general migration process.
Find hardened images for your app.
A hardened image may have several variants. Inspect the image tags and find the image variant that meets your needs.
Update the base image in your Dockerfile.
Update the base image in your application's Dockerfile to the hardened image you found in the previous step. For
framework images, this is typically going to be an image tagged as dev because it has the tools needed to install
packages and dependencies.
For multi-stage Dockerfiles, update the runtime image in your Dockerfile.
To ensure that your final image is as minimal as possible, you should use a multi-stage build. All stages in your
Dockerfile should use a hardened image. While intermediary stages will typically use images tagged as dev, your
final runtime stage should use a non-dev image variant.
Install additional packages
Docker Hardened Images contain minimal packages in order to reduce the potential attack surface. You may need to install additional packages in your Dockerfile. Inspect the image variants to identify which packages are already installed.
Only images tagged as dev typically have package managers. You should use a multi-stage Dockerfile to install the
packages. Install the packages in the build stage that uses a dev image. Then, if needed, copy any necessary
artifacts to the runtime stage that uses a non-dev image.
For Alpine-based images, you can use apk to install packages. For Debian-based images, you can use apt-get to
install packages.
The following are common issues that you may encounter during migration.
The hardened images intended for runtime don't contain a shell nor any tools for debugging. The recommended method for debugging applications built with Docker Hardened Images is to use Docker Debug to attach to these containers. Docker Debug provides a shell, common debugging tools, and lets you install other tools in an ephemeral, writable layer that only exists during the debugging session.
By default image variants intended for runtime, run as the nonroot user. Ensure that necessary files and directories are accessible to the nonroot user. You may need to copy files to different directories or change permissions so your application running as the nonroot user can access them.
Non-dev hardened images run as a nonroot user by default. As a result, applications in these images can't bind to
privileged ports (below 1024) when running in Kubernetes or in Docker Engine versions older than 20.10. To avoid issues,
configure your application to listen on port 1025 or higher inside the container, even if you map it to a lower port on
the host. For example, docker run -p 80:8080 my-image will work because the port inside the container is 8080, and
docker run -p 80:81 my-image won't work because the port inside the container is 81.
By default, image variants intended for runtime don't contain a shell. Use dev images in build stages to run shell
commands and then copy any necessary artifacts into the runtime stage. In addition, use Docker Debug to debug containers
with no shell.
The DHI Jenkins runtime image does not include curl, wget, or other HTTP clients. Do not use these tools in
healthchecks or scripts that run inside the container. Use java directly for connectivity checks, or use Docker Debug
to install tools temporarily for debugging purposes.
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.