> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/d/docker.md).

# Docker

Docker Engine runs containers on a host and exposes a remote API. OctoXLabs reads the container and image lists of a Docker host and adds them to the inventory as services.

## Use cases

* List containers that are running on a Docker host.
* Review images stored on a Docker host to find outdated ones.

## Before you begin

### Network

| Source              | Destination | Port                            | Protocol                         |
| ------------------- | ----------- | ------------------------------- | -------------------------------- |
| OctoXLabs connector | Docker host | 2376 (TLS) or 2375 (plain HTTP) | HTTPS (HTTP if Is Secure is off) |

A daemon that listens on plain HTTP has no authentication. Anyone who can reach the port has full control of the host. Use it only on isolated test environments.

### Required permissions

| Scope or role                                                                | Permission | Needed for                    |
| ---------------------------------------------------------------------------- | ---------- | ----------------------------- |
| Client certificate signed by the daemon CA (`extendedKeyUsage = clientAuth`) | Read       | Container list and image list |

The adapter only reads container and image lists. If an authorization plugin is in use, allow read access to these lists for the client certificate.

## Create credentials in Docker

{% stepper %}
{% step %}

### Enable TLS on the daemon

Start the daemon with `--tlsverify`, `--tlscacert`, `--tlscert`, `--tlskey` and `-H=0.0.0.0:2376`, or set the same values in `/etc/docker/daemon.json`.
{% endstep %}

{% step %}

### Create a client certificate

Create a client key and a certificate signing request. Sign it with the daemon CA using the `extendedKeyUsage = clientAuth` extension.
{% endstep %}

{% step %}

### Upload the files

Upload the resulting `cert.pem` and `key.pem` in OctoXLabs. The key must not be encrypted.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter          | Required                 | Type              | Default | Description                                   |
| ------------------ | ------------------------ | ----------------- | ------- | --------------------------------------------- |
| IP                 | Yes                      | String            | None    | IP address or host name of the Docker host.   |
| Port               | No                       | Integer           | `2376`  | Docker Engine API port.                       |
| Client Certificate | Yes when Is Secure is on | File (PEM)        | None    | Client certificate `cert.pem`.                |
| Client Private Key | Yes when Is Secure is on | File (PEM)        | None    | Unencrypted private key `key.pem`.            |
| Fetch Containers   | No                       | Boolean           | `True`  | Fetch all containers, including stopped ones. |
| Fetch Images       | No                       | Boolean           | `True`  | Fetch images on the host.                     |
| Is Secure          | No                       | Boolean           | `True`  | Use HTTPS with the client certificate.        |
| Timeout            | No                       | Integer (seconds) | `60`    | Time to wait for API responses.               |

## Troubleshooting

| Error message                                       | Cause                                                           | Fix                                                                   |
| --------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------- |
| `A PEM file is required when is_secure is enabled.` | Client Certificate or Client Private Key is missing or not PEM. | Upload both PEM files, or turn Is Secure off for a plain HTTP daemon. |

## Change history

{% hint style="info" %}
Available starting from version 6.9.1.
{% endhint %}
