Chapter 38. Docker


Docker Component

Available as of Camel 2.15
Camel component for communicating with Docker.
The Docker Camel component leverages the docker-java via the Docker Remote API.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-docker</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

docker://[operation]?[options]
Where operation is the specific action to perform on Docker.

Header Strategy

All URI option can be passed as Header properties. Values found in a message header take precedence over URI parameters. A header property takes the form of a URI option prefixed with *CamelDocker* as shown below
URI Option Header Property
containerId CamelDockerContainerId

General Options

The following parameters can be used with any invocation of the component
Option Header Description Default Value
host CamelDockerHost Mandatory: Docker host localhost
port CamelDockerPort Mandatory:Docker port 2375
username CamelDockerUserName User name to authenticate with
password CamelDockerPassword Password to authenticate with
email CamelDockerEmail Email address associated with the user
secure CamelDockerSecure Use HTTPS communication false
requestTimeout CamelDockerRequestTimeout Request timeout for response (in seconds) 30
certPath CamelDockerCertPath Location containing the SSL certificate chain

Consumer Operations

The consumer supports the following operations.
Operation Options Description Produces
events initialRange Monitor Docker events (Streaming) Event

Producer Operations

The following producer operations are available.
Misc Operation Options Description Returns
auth Check auth configuration
info System wide information Info
ping Ping the Docker server
version Show the docker version information Version
Image Operation Options Description Body Content Returns
image/list filter, showAll List images List<Image>
image/create repository Create an image InputStream CreateImageResponse
image/build noCache, quiet, remove, tag Build an image from Dockerfile via stdin InputStream or File InputStream
image/pull repository, registry, tag Pull an image from the registry InputStream
image/push name Push an image on the registry InputStream
image/search term Search for images List<SearchItem>
image/remove imageId Remove an image
image/tag imageId, repository, tag, force Tag an image into a repository
image/inspect imageId Inspect an image InspectImageResponse
Container Operation Options Description Body Content Returns
container/list showSize, showAll, before, since, limit, List containers initialRange List<Container>
container/create imageId, name, exposedPorts, workingDir, disableNetwork, hostname, user, tty, stdInOpen, stdInOnce, memoryLimit, memorySwap, cpuShares, attachStdIn, attachStdOut, attachStdErr, env, cmd, dns, image, volumes, volumesFrom Create a container CreateContainerResponse
container/start
containerId, binds, links, lxcConf, portBindings, privileged, publishAllPorts, dns, dnsSearch, volumesFrom, networkMode, devices, restartPolicy, capAdd, capDrop
Start a container
container/inspect containerId Inspect a container InspectContainerResponse
container/wait containerId Wait a container Integer
container/log containerId, stdOut, stdErr, timestamps, followStream, tailAll, tail Get container logs InputStream
container/attach containerId, stdOut, stdErr, timestamps, logs, followStream Attach to a container InputStream
container/stop containerId, timeout Stop a container
container/restart containerId, timeout Restart a container
container/diff containerId Inspect changes on a container ChangeLog
container/kill containerId, signal Kill a container
container/top containerId, psArgs List processes running in a container TopContainerResponse
container/pause containerId Pause a container
container/unpause containerId Unpause a container
container/commit containerId, repository, message, tag, attachStdIn, attachStdOut, attachStdErr, cmd, disableNetwork, pause, env, exposedPorts, hostname, memory, memorySwap, openStdIn, portSpecs, stdInOnce, tty, user, volumes, hostname Create a new image from a container's changes String
container/copyfile containerId, resource, hostPath Copy files or folders from a container InputStream
container/remove containerId, force, removeVolumes Remove a container

Examples

The following example consumes events from Docker:
from("docker://events?host=192.168.59.103&port=2375").to("log:event");
The following example queries Docker for system wide information
from("docker://info?host=192.168.59.103&port=2375").to("log:info");
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.