While alive, THIS client instance keeps its daemon connection open across requests and reuses it for consecutive idempotent GET calls — all other requests keep opening fresh connections, so a stale-connection retry can never replay a side effect.
More...
While alive, THIS client instance keeps its daemon connection open across requests and reuses it for consecutive idempotent GET calls — all other requests keep opening fresh connections, so a stale-connection retry can never replay a side effect.
If a reused connection turns out dead (the daemon or an intermediary closed it while idle), the request is transparently retried ONCE on a fresh connection; a deadline expiry (TransportTimeoutError) is never retried. The cached connection is closed when the session ends.
Sessions make the instance stateful: do not share one DockerClient instance across threads while a session is active (copies made while a session is active do not inherit it and stay independent). The client must outlive the Session — the guard holds a reference.