[[Docker-CamelDockercomponent]]
Camel Docker component
~~~~~~~~~~~~~~~~~~~~~~

*Available as of Camel 2.15*

Camel component for communicating with Docker.

The Docker Camel component leverages the
https://github.com/docker-java/docker-java[docker-java] via the
https://docs.docker.com/reference/api/docker_remote_api[Docker Remote
API].

Maven users will need to add the following dependency to their `pom.xml`
for this component:

[source,xml]
------------------------------------------------------------
<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>
------------------------------------------------------------

[[Docker-URIformat]]
URI format
^^^^^^^^^^

[source,java]
------------------------------
docker://[operation]?[options]
------------------------------

Where *operation* is the specific action to perform on Docker.

[[Docker-HeaderStrategy]]
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

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|URI Option |Header Property

|containerId |CamelDockerContainerId
|=======================================================================

[[Docker-GeneralOptions]]
General Options
^^^^^^^^^^^^^^^

The following parameters can be used with any invocation of the
component

[width="100%",cols="10%,10%,70%,10%",options="header",]
|=======================================================================
|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 |
|=======================================================================
 

[[Docker-ConsumerOperations]]
Consumer Operations
^^^^^^^^^^^^^^^^^^^

The consumer supports the following operations.

[width="100%",cols="10%,10%,70%,10%",options="header",]
|=======================================================================
|Operation |Options |Description |Produces

|events |initialRange |Monitor Docker events (Streaming) |Event
|=======================================================================

[[Docker-ProducerOperations]]
Producer Operations
^^^^^^^^^^^^^^^^^^^

The following producer operations are available.

[width="100%",cols="10%,10%,70%,10%",options="header",]
|=======================================================================
|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

|=======================================================================

[width="100%",cols="10%,10%,60%,10%,10%",options="header",]
|=======================================================================
|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
|=======================================================================


[width="100%",cols="10%,30%,40%,10%,10%",options="header",]
|=======================================================================
|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 | |
|=======================================================================

[[Docker-Examples]]
Examples
^^^^^^^^

The following example consumes events from Docker:

[source,java]
----------------------------------------------------------------------
from("docker://events?host=192.168.59.103&port=2375").to("log:event");
----------------------------------------------------------------------

 

The following example queries Docker for system wide information

[source,java]
-------------------------------------------------------------------
from("docker://info?host=192.168.59.103&port=2375").to("log:info");
-------------------------------------------------------------------

 

 

 
