Repository navigation
Configuration
A service becomes a Bouncer Service by having an x-bouncer block. Everything else is standard Compose: the replica count is deploy.replicas, the ports are the service's ports: and expose:. Your compose file is never rewritten; the derived project is built in memory on every run.
services:
api:
image: registry/api:2.3
deploy: { replicas: 3 }
restart: unless-stopped
ports:
- "127.0.0.1:8080:8080" # Envoy publishes 127.0.0.1:8080 → replicas :8080
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:8080/health"]
interval: 5s
x-bouncer:
bounce_method: crossover
bounce_margin_factor: 0.95
bounce_overprovision_factor: 1.0
min_task_uptime: 10s
bounce_health_timeout: 300s
healthcheck: { mode: http, uri: /health }
drain_method: envoy
drain_method_params: { delay: 95s }
history_max: 3
worker:
image: registry/worker:1.4
expose: ["8001"] # internal Service: Envoy listens on worker:8001
x-bouncer: {} # all defaultsx-bouncer: {} is a complete configuration: every key has a default.
All problems in a service's block are collected and reported together. Any configuration error exits with code 2 before anything is pulled, locked or changed.
| Key | Type | Default | Validation |
|---|---|---|---|
bounce_method |
string | crossover |
one of crossover, upthendown, downthenup, brutal
|
bounce_margin_factor |
number | 0.95 |
0 to 1 inclusive |
bounce_overprovision_factor |
number | 1.0 |
0 to 1 inclusive |
min_task_uptime |
duration | 10s |
Go duration, not negative |
bounce_health_timeout |
duration | 300s |
Go duration, not negative |
healthcheck.mode |
string | http |
only http (or omitted) |
healthcheck.uri |
string | unset: GET /, any status below 500 passes |
any path; set, only 2xx passes; empty keeps the default |
drain_method |
string | envoy |
one of envoy, http, noop
|
drain_method_params.delay |
duration | 60s |
Go duration, not negative |
drain_method_params.drain |
HTTP call | none | required when drain_method: http
|
drain_method_params.is_safe_to_kill |
HTTP call | none | required when drain_method: http
|
drain_method_params.stop_draining |
HTTP call | none | optional |
history_max |
integer | 3 |
>= 0 |
proxy_image |
string | envoyproxy/envoy:v1.39.1 |
not validated; see below |
Durations use Go syntax: 500ms, 95s, 5m, 1h30m. A bare number such as 60 is rejected.
Unknown keys anywhere in the block are rejected (x-bouncer: json: unknown field "..."), so a typo never silently falls back to a default.
How old replicas are replaced. See Bounce methods for animations and when to pick each:
-
crossover(default): rolling, bounded by the two factors below. -
upthendown: all new replicas healthy before any old one drains. -
downthenup: all old replicas drained before any new one starts (a gap in service). -
brutal: start all new, then stop all old without health gates or drain waits (development only).
Used by crossover only; the other methods fix their own limits. With N = deploy.replicas:
-
maxUnavailable = floor(N × (1 − bounce_margin_factor)): how many of the N may be missing during the bounce. -
maxSurge = ceil(N × bounce_overprovision_factor): how many extra replicas may exist.
If both come out as 0, the surge becomes 1 so the bounce can always progress. The Bounce methods page has the rounding rules and worked examples.
How long a new replica must stay continuously healthy (Envoy, and Docker if it has a healthcheck) before it counts towards replacing an old one. It gates draining only; up finishes once all N new replicas are healthy. See Draining and health.
How long a new replica has to become healthy, counted from when it was created or from the start of the current run, whichever is later. When it expires the bounce fails, unhealthy new replicas are removed, and up exits 1; old replicas keep serving. It also sets how soon an abandoned lock counts as stale. See Draining and health.
Envoy's active health check on every replica:
healthcheck: { mode: http, uri: /ready }Only mode: http exists. Envoy sends GET <uri> to each replica on the Service's first port every second. With no uri, Envoy sends GET / and any status from 200 to 499 passes (the app is up and speaking HTTP; a 404 or 401 on / is fine, a 5xx or no answer fails), so a service with no health endpoint works as is. With a uri set, only a 2xx passes. This is independent of the Compose healthcheck: on the service, which stays on the replicas and is optional.
How an old replica is taken out of service: envoy (wait for its connections to close), http (call your hooks), noop (stop at once). delay is the upper bound on the wait. An HTTP call is:
drain_method: http
drain_method_params:
delay: 120s
drain: { method: POST, path: /admin/drain, success_codes: [200, 202] }
is_safe_to_kill: { path: /admin/idle } # GET, any 2xx
stop_draining: { method: POST, path: /admin/undrain }| Field | Default |
|---|---|
method |
GET |
path |
none (send a path) |
success_codes |
any 2xx
|
Semantics, including when stop_draining is sent, are on Draining and health.
How many previous revisions are kept in the replicas' labels, in addition to the current one. history shows them and undo --to-revision can target them. 0 keeps none, so undo has nothing to go back to.
The Envoy image for this Service's proxy. The default is pinned. A replacement must be based on the official Ubuntu-based envoyproxy/envoy image: the proxy's entrypoint, health check and Bouncer's admin calls run bash (with /dev/tcp), cat, grep, mv, mkdir and printf inside it, so distroless variants do not work. The lock container is created from the proxy image of the first Service in name order.
A Service needs at least one port, from ports:, expose: or both. The proxy takes them over: it publishes the ports: and exposes the expose: entries, and listens with Envoy on each distinct container (target) port. Replicas get no published ports; they keep expose:.
-
ports:short or long syntax.protocolmust betcp(or omitted). Long syntax may setapp_protocol, but onlyhttpis accepted. -
expose:entries are single ports,"8001"or"8001/tcp". Ranges andudpare rejected. - Two published ports with the same target share one Envoy listener and cluster. Two Services may use the same container port: each has its own proxy.
- The first port (the first
ports:entry, else the firstexpose:entry) is the one Envoy health-checks on and the onedrain_method: httpcalls go to. - Envoy's admin interface listens on
127.0.0.1:9901inside the proxy. If a Service uses container port9901, admin moves to19901; if it uses both, that is a configuration error.
ports:
- "8080:8080" # host 8080 → proxy :8080 → replicas :8080
- target: 8081
published: "8081"
host_ip: 127.0.0.1
app_protocol: http # allowed; anything else is rejected
expose: ["9000"] # proxy :9000 on the project network onlyA Service runs a proxy plus several replicas, so settings that pin one container's identity are rejected:
| Setting | Why |
|---|---|
container_name |
it runs several replicas |
mac_address (service level) |
the proxy and every replica would share it |
networks.<net>.ipv4_address, ipv6_address, mac_address
|
same |
any x-bouncer key not listed above |
catches typos |
healthcheck.mode other than http
|
only HTTP health checks exist |
ports with protocol: udp, app_protocol other than http
|
only HTTP over TCP is proxied |
expose ranges or udp
|
one TCP port per entry |
no ports: and no expose:
|
nothing to proxy |
a service named <S>-app next to a Service S
|
that name is reserved for the replicas |
Network aliases are allowed: they move to the proxy, so clients resolve them to Envoy, not to an individual replica.
up pulls every image it needs before taking the lock, so a slow or failing pull never leaves a bounce half done. Compose itself is then told never to pull.
- Without
--pull, each service'spull_policydecides:alwayspulls,neverandbuildskip, and anything else (missing, the default, ordaily/weekly/every_<duration>) pulls only when the image is not present locally. -
up --pull always|missing|neveroverrides every service's policy for that run. - The proxy image is pulled when missing (unless
--pull never), because the proxy and the lock container are created from it. -
docker bouncer pull [SERVICE…]pulls every selected image, plus the proxy image, unconditionally, and changes nothing else. - A pull error exits
2; nothing has changed.
undo also pulls the images of the revisions it restores, before taking the lock, using each service's pull_policy.
N is the service's deploy.replicas (or scale:), default 1. The replica count is not part of a revision's spec, so changing only deploy.replicas scales without a bounce: scaling up adds replicas of the current revision next to the existing ones, and scaling down drains the surplus with the configured drain method. No new revision is created.
A Service bounces when the spec hash of its replica config differs from the bouncer.spec-hash label of the running replicas. The spec is the service minus ports:, network aliases, x-bouncer, the replica count and Bouncer's own labels. So:
- a new image, command, environment variable, volume, label, healthcheck, resource limit and so on triggers a bounce;
- changing
deploy.replicasscales without one; - changing
x-bouncersettings alone does not bounce (they take effect on the next bounce); changes that alter the proxy's own definition, such asports,proxy_imageorhealthcheck.uri, recreate the proxy instead (see Troubleshooting); - keys loaded from an
env_fileare stripped from the spec before hashing, so changing only a value inside an env file does not trigger a bounce. Change something else (for example a label) to roll it out. See How it works.