Keploy logo
Docker logo

Keploy as a Docker testing framework

Keploy records traffic inside a running Docker container, capturing the requests a service serves and every downstream call it makes, then replays them in CI. The resulting tests need no Compose stack, no Testcontainers, and no Docker daemon in the runner.

Generate Docker tests free
keploy record -c "docker compose up orders"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a Docker team

Any image, any language

Keploy records inside the container at the socket layer, so the base image, language, and framework do not matter. A Compose service, a standalone container, or a plain binary all record the same way.

  • Any base image or runtime
  • Compose services and standalone containers
  • No Dockerfile change
  • No entrypoint wrapper in the image
The problem

Why Docker integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing Docker: by hand, with Docker Compose + Testcontainers, or with Keploy

Compose and Testcontainers start a real stack in every job and need a Docker runtime to do it. Keploy records that stack once and replays it as a plain process.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Docker vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
deps_fakes.js
hand-written
// Hand-written: one fake per containerised dependency.
// Three services in Compose become three fakes to maintain.
exports.fakePostgres = {
query: async () => ({ rows: [{ id: 'ord_1', amount_minor: 4200 }] }),
};
 
exports.fakeRedis = {
// Always a hit, so the miss path is never exercised.
get: async (key) => JSON.stringify({ state: 'NEW' }),
setex: async () => 'OK',
};
 
exports.fakeKafka = {
// No serialiser runs, no partition is chosen, no offset returns.
send: async () => [{ partition: 0, baseOffset: '0' }],
};

Three fakes standing in for three images, each encoding a guess about behaviour nothing verifies against the real container.

Docker Compose + Testcontainers1–2 hours
docker-compose.test.yml
tool-assisted
# A test stack: real images, started in every job.
services:
orders:
build: .
depends_on:
postgres: { condition: service_healthy }
redis: { condition: service_started }
kafka: { condition: service_healthy }
postgres:
image: postgres:16
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 2s
retries: 15
redis:
image: redis:7
kafka:
image: confluentinc/cp-kafka:7.6.0
healthcheck:
test: ["CMD", "kafka-topics", "--bootstrap-server", "localhost:9092", "--list"]
interval: 5s
retries: 20

Genuine fidelity, and a second deployment definition to maintain — plus four image pulls and two healthcheck loops before the first assertion.

With Keploy~5 minutes
ci-replay.yml
auto-generated
# Replay recorded container traffic — no daemon needed.
name: integration
on: [pull_request]
jobs:
replay:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Keploy
run: curl -sSL https://keploy.io/install.sh | bash
- name: Build
run: npm ci && npm run build
# No Compose, no image pulls, no healthcheck waits.
- name: Replay
run: keploy test -c "node dist/server.js" --delay 8

The recording already contains Postgres, Redis, and Kafka responses, so this job exercises the same paths without starting a single container.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

Docker testing tools, compared

The options a team on service and platform integrations actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your Docker app once, replay it forever

Keploy sits below your Docker process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a Docker service and captures the dependency calls it makes.

An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Mock coverage

What Keploy mocks for Docker, with zero config

7 of the 7 dependencies a typical Docker service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.

Quick start

Your first Docker test suite in under five minutes

Every command below runs against your existing Docker service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.

    keploy record -c "docker compose up orders"
  3. 3Exercise the paths you care about

    Record once with your Compose stack up. Every database, cache, and broker call the request triggered is captured, so later runs need none of them.

    docker compose up -d postgres redis kafka
    curl -X POST localhost:8080/orders/ord_1/confirm -d '{"paymentToken":"tok_123"}'
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

    keploy test -c "node dist/server.js" --delay 8

Ready to try it on your own Docker service?

FAQ

Docker testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.