Docker

The Docker Infrastructure Agent is a containerized version of our Host Agent that:

  • Collects host-level metrics by querying the Docker daemon via its bridge gateway.
  • Reads and forwards container logs through bind-mounted volumes.
  • Exposes ports for health checks and metrics scraping.

This guide walks you through installing, configuring, and verifying the Docker Infra Agent on your host.

Prerequisites

  1. Docker Engine v19.03+ installed and running on each host.
  2. cgroup memory management enabled (required to collect container metrics).
  3. Internet access (direct or via proxy) from the host to install.middleware.io and your <MW_UID>.middleware.io endpoint.
  4. *Only one Infra Agent per host (multiple agents may cause conflicts).

Installation

1 Run the Install Script

Copy and paste the command below (replace <MW_API_KEY> and <MW_TARGET>):

1MW_API_KEY="<MW_API_KEY>" \
2MW_TARGET="https://<MW_UID>.middleware.io:443" \
3bash -c "$(curl -fsSL https://install.middleware.io/scripts/docker-install.sh)"

If you don’t see your API key or target, log in to the Installation page and copy the command directly.

Install with Custom Host Tags (Optional)

Attach metadata (e.g., env:prod or role:web) to filter and group hosts in the UI:

1MW_HOST_TAGS=key1:value1,key2:value2,... \
2MW_API_KEY="<MW_API_KEY>" MW_TARGET=https://<MW_UID>.middleware.io:443 \
3bash -c "$(curl -L https://install.middleware.io/scripts/docker-install.sh)"

Tags appear under Infrastructure → [Your Host] → System Information in the Middleware.io UI.

2 Verify Installation

Run:

1docker ps -a --filter ancestor=ghcr.io/middleware-labs/mw-host-agent:master
Docker Agent
  • Up or Exited status means the container ran successfully.
  • A blank result indicates the agent never started (check the install logs).

3 Check Your Dashboard

  1. Log in to https://app.middleware.io.
  2. Navigate to Infrastructure → Installation.
  3. Confirm your host appears with a recent “Last seen” timestamp (usually within 1–2 minutes).
Docker Agent

Metrics can take a few minutes to show up. If nothing appears after 5 minutes, see Troubleshooting.

Docker Compose

To run the container with Docker Compose or to review the necessary ports, volumes, privileges, and network mode for running it, please refer to the Docker Compose file below for more details:

1version: "3.8"
2services:
3  mw-host-agent:
4    image: ghcr.io/middleware-labs/mw-host-agent:master
5    restart: unless-stopped
6    environment:
7      - MW_API_KEY=<MW_API_KEY>
8      - MW_TARGET=https://<MW_UID>.middleware.io:443
9    ports:
10      - "9319:9319"
11      - "9320:9320"
12    volumes:
13      - /var/run/docker.sock:/var/run/docker.sock:ro
14      - /proc:/host/proc:ro
15      - /sys/fs/cgroup:/host/sys/fs/cgroup:ro

Next, bring it up:

1docker-compose up -d
2docker-compose ps
Docker Agent

Troubleshooting

  • Socket not found

    1Error: no such file or directory: /var/run/docker.sock

    Ensure Docker is installed and the socket path hasn’t been customized (DOCKER_HOST).

  • Permission denied on mounts Run the install command with sudo, or adjust file permissions temporarily:

    1sudo bash -c "$(curl -L https://install.middleware.io/scripts/docker-install.sh)"
  • Metrics don’t appear in UI Confirm the following:

    1. Outbound port 443 is open.
    2. Only one Infra Agent per host/container is running.
    3. No corporate proxy is blocking traffic (set HTTP_PROXY/HTTPS_PROXY if needed).
  • Container immediately exits:

    1docker logs <container_id>

Inspect the logs for missing env vars or connectivity errors.

Uninstall

To completely remove the agent container:

1docker stop `docker ps -a -q --filter ancestor=ghcr.io/middleware-labs/mw-host-agent:master`
2
3docker rm   `docker ps -a -q --filter ancestor=ghcr.io/middleware-labs/mw-host-agent:master`

Collected Metrics

MetricDescriptionShown as
container.blockio.io_merged_recursiveNumber of bios/requests merged into requests belonging to this cgroup and its descendant cgroups (Only available with cgroups v1).operation
container.blockio.io_queued_recursiveNumber of requests queued up for this cgroup and its descendant cgroups (Only available with cgroups v1).operation
container.blockio.io_service_bytes_recursiveNumber of bytes transferred to/from the disk by the group and descendant groups.byte
container.blockio.io_service_time_recursiveTotal amount of time in nanoseconds between request dispatch and request completion for the IOs done by this cgroup and descendant cgroups (Only available with cgroups v1).nanosecond
container.blockio.io_serviced_recursiveNumber of IOs (bio) issued to the disk by the group and descendant groups (Only available with cgroups v1).operation
container.blockio.io_time_recursiveDisk time allocated to cgroup (and descendant cgroups) per device in milliseconds (Only available with cgroups v1).millisecond
container.blockio.io_wait_time_recursiveTotal amount of time the IOs for this cgroup (and descendant cgroups) spent waiting in the scheduler queues for service (Only available with cgroups v1).nanosecond
container.blockio.sectors_recursiveNumber of sectors transferred to/from disk by the group and descendant groups (Only available with cgroups v1).sector
container.cpu.limit (gauge)CPU limit set for the container.cpu core
container.cpu.logical.count (gauge)Number of cores available to the container.cpu core
container.cpu.shares (gauge)CPU shares set for the container.1
container.cpu.throttling_data.periodsNumber of periods with throttling active.period
container.cpu.throttling_data.throttled_periodsNumber of periods when the container hits its throttling limit.period
container.cpu.throttling_data.throttled_timeAggregate time the container was throttled.nanosecond
container.cpu.usage.kernelmodeTime spent by tasks of the cgroup in kernel mode (Linux). Time spent by all container processes in kernel mode (Windows).nanosecond
container.cpu.usage.percpuPer-core CPU usage by the container (Only available with cgroups v1).nanosecond
container.cpu.usage.systemSystem CPU usage, as reported by docker.nanosecond
container.cpu.usage.totalTotal CPU time consumed.nanosecond
container.cpu.usage.usermodeTime spent by tasks of the cgroup in user mode (Linux). Time spent by all container processes in user mode (Windows).nanosecond
container.cpu.utilization (gauge)Percent of CPU used by the container.1
container.memory.active_anonThe amount of anonymous memory that has been identified as active by the kernel.byte
container.memory.active_fileCache memory that has been identified as active by the kernel.byte
container.memory.anonAmount of memory used in anonymous mappings such as brk(), sbrk(), and mmap(MAP_ANONYMOUS) (Only available with cgroups v2).byte
container.memory.cacheThe amount of memory used by the processes of this control group that can be associated precisely with a block on a block device (Only available with cgroups v1).byte
container.memory.dirtyBytes that are waiting to get written back to the disk, from this cgroup (Only available with cgroups v1).byte
container.memory.failsNumber of times the memory limit was hit.failure
container.memory.fileAmount of memory used to cache filesystem data, including tmpfs and shared memory (Only available with cgroups v2).byte
container.memory.hierarchical_memory_limitThe maximum amount of physical memory that can be used by the processes of this control group (Only available with cgroups v1).byte
container.memory.hierarchical_memsw_limitThe maximum amount of RAM + swap that can be used by the processes of this control group (Only available with cgroups v1).byte
container.memory.inactive_anonThe amount of anonymous memory that has been identified as inactive by the kernel.byte
container.memory.inactive_fileCache memory that has been identified as inactive by the kernel.byte
container.memory.mapped_fileIndicates the amount of memory mapped by the processes in the control group (Only available with cgroups v1).byte
container.memory.percent (gauge)Percentage of memory used.1
container.memory.pgfaultIndicate the number of times that a process of the cgroup triggered a page fault.fault
container.memory.pgmajfaultIndicate the number of times that a process of the cgroup triggered a major fault.fault
container.memory.pgpginNumber of pages read from disk by the cgroup (Only available with cgroups v1).operation
container.memory.pgpgoutNumber of pages written to disk by the cgroup (Only available with cgroups v1).operation
container.memory.rssThe amount of memory that doesn't correspond to anything on disk: stacks, heaps, and anonymous memory maps (Only available with cgroups v1).byte
container.memory.rss_hugeNumber of bytes of anonymous transparent hugepages in this cgroup (Only available with cgroups v1).byte
container.memory.total_active_anonThe amount of anonymous memory that has been identified as active by the kernel. Includes descendant cgroups (Only available with cgroups v1).byte
container.memory.total_active_fileCache memory that has been identified as active by the kernel. Includes descendant cgroups (Only available with cgroups v1).byte
container.memory.total_cacheTotal amount of memory used by the processes of this cgroup (and descendants) that can be associated with a block on a block device. Also accounts for memory used by tmpfs (Only available with cgroups v1).byte
container.memory.total_dirtyBytes that are waiting to get written back to the disk, from this cgroup and descendants (Only available with cgroups v1).byte
container.memory.total_inactive_anonThe amount of anonymous memory that has been identified as inactive by the kernel. Includes descendant cgroups (Only available with cgroups v1).byte
container.memory.total_inactive_fileCache memory that has been identified as inactive by the kernel. Includes descendant cgroups (Only available with cgroups v1).byte
container.memory.total_mapped_fileIndicates the amount of memory mapped by the processes in the control group and descendant groups (Only available with cgroups v1).byte
container.memory.total_pgfaultIndicate the number of times that a process of the cgroup (or descendant cgroups) triggered a page fault (Only available with cgroups v1).fault
container.memory.total_pgmajfaultIndicate the number of times that a process of the cgroup (or descendant cgroups) triggered a major fault (Only available with cgroups v1).fault
container.memory.total_pgpginNumber of pages read from disk by the cgroup and descendant groups (Only available with cgroups v1).operation
container.memory.total_pgpgoutNumber of pages written to disk by the cgroup and descendant groups (Only available with cgroups v1).operation
container.memory.total_rssThe amount of memory that doesn't correspond to anything on disk: stacks, heaps, and anonymous memory maps. Includes descendant cgroups (Only available with cgroups v1).byte
container.memory.total_rss_hugeNumber of bytes of anonymous transparent hugepages in this cgroup and descendant cgroups (Only available with cgroups v1).byte
container.memory.total_unevictableThe amount of memory that cannot be reclaimed. Includes descendant cgroups (Only available with cgroups v1).byte
container.memory.total_writebackNumber of bytes of file/anon cache that are queued for syncing to disk in this cgroup and descendants (Only available with cgroups v1).byte
container.memory.unevictableThe amount of memory that cannot be reclaimed.byte
container.memory.usage.limitMemory limit of the container.byte
container.memory.usage.maxMaximum memory usage.byte
container.memory.usage.totalMemory usage of the container. This excludes the cache.byte
container.memory.writebackNumber of bytes of file/anon cache that are queued for syncing to disk in this cgroup (Only available with cgroups v1).byte
container.network.io.usage.rx_bytesBytes received by the container.byte
container.network.io.usage.rx_droppedIncoming packets dropped.packets
container.network.io.usage.rx_errorsReceived errors.error
container.network.io.usage.rx_packetsPackets received.packets
container.network.io.usage.tx_bytesBytes sent.byte
container.network.io.usage.tx_droppedOutgoing packets dropped.packets
container.network.io.usage.tx_errorsSent errors.error
container.network.io.usage.tx_packetsPackets sent.packets
container.pids.countNumber of pids in the container's cgroup.process id
container.pids.limitMaximum number of pids in the container's cgroup.process id
container.restartsNumber of restarts for the container.restart
container.status (gauge)Container Status => 0-created 1-running 2-paused 3-restarting 4-removing 5-exited 6-deadcount
container.uptime (gauge)Time elapsed since container start time.second

Need assistance or want to learn more about Middleware? Contact our support team at [email protected] or join our Slack channel.