Skip to content

Commit 8c9668c

Browse files
Copilotlpcox
andauthored
feat: fail fast when DOCKER_HOST points to an external daemon (workflow-scope DinD) (#1909)
* Initial plan * feat: detect workflow-scope DinD (DOCKER_HOST) and fail fast Add checkDockerHost() to src/cli.ts that inspects DOCKER_HOST on startup. If it points at a non-default socket (e.g. tcp://localhost:2375 for a DinD sidecar), AWF exits immediately with a clear error explaining why it is incompatible and pointing at the new docs section. Also add a "Workflow-Scope DinD Incompatibility" section to docs/usage.md documenting the root cause, the error message users will see, and the --enable-dind workaround for agents that genuinely need Docker access. Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/d99ee10d-b3d6-4811-a197-9eb8bb15da2a --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Landon Cox <landon.cox@microsoft.com>
1 parent 90c7f38 commit 8c9668c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/cli.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,15 @@ export function applyAgentTimeout(
891891
logger.info(`Agent timeout set to ${result.minutes} minutes`);
892892
}
893893

894+
/**
895+
* The set of DOCKER_HOST values that point to the local Docker daemon and are
896+
* therefore compatible with AWF's network isolation model.
897+
*/
898+
const LOCAL_DOCKER_HOST_VALUES = new Set([
899+
'unix:///var/run/docker.sock',
900+
'unix:///run/docker.sock',
901+
]);
902+
894903
/**
895904
* Checks whether DOCKER_HOST is set to an external daemon that is incompatible
896905
* with AWF.
@@ -903,13 +912,9 @@ export function applyAgentTimeout(
903912
* - The iptables DNAT rules set up by awf-iptables-init
904913
* - Port-binding expectations between containers
905914
*
906-
* Any `unix://` socket (including non-default paths) is accepted because it
907-
* still refers to a local Docker daemon. Only remote schemes (`tcp://`,
908-
* `ssh://`, etc.) are rejected.
909-
*
910915
* @param env - Environment variables to inspect (defaults to process.env)
911-
* @returns `{ valid: true }` when DOCKER_HOST is absent or uses a unix socket;
912-
* `{ valid: false, error: string }` for remote daemon schemes.
916+
* @returns `{ valid: true }` when DOCKER_HOST is absent or points at the local
917+
* socket; `{ valid: false, error: string }` otherwise.
913918
*/
914919
export function checkDockerHost(
915920
env: Record<string, string | undefined> = process.env
@@ -920,7 +925,7 @@ export function checkDockerHost(
920925
return { valid: true };
921926
}
922927

923-
if (dockerHost.startsWith('unix://')) {
928+
if (LOCAL_DOCKER_HOST_VALUES.has(dockerHost)) {
924929
return { valid: true };
925930
}
926931

0 commit comments

Comments
 (0)