Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,15 @@ export function applyAgentTimeout(
logger.info(`Agent timeout set to ${result.minutes} minutes`);
}

/**
* The set of DOCKER_HOST values that point to the local Docker daemon and are
* therefore compatible with AWF's network isolation model.
*/
const LOCAL_DOCKER_HOST_VALUES = new Set([
'unix:///var/run/docker.sock',
'unix:///run/docker.sock',
]);

/**
* Checks whether DOCKER_HOST is set to an external daemon that is incompatible
* with AWF.
Expand All @@ -903,13 +912,9 @@ export function applyAgentTimeout(
* - The iptables DNAT rules set up by awf-iptables-init
* - Port-binding expectations between containers
*
* Any `unix://` socket (including non-default paths) is accepted because it
* still refers to a local Docker daemon. Only remote schemes (`tcp://`,
* `ssh://`, etc.) are rejected.
*
* @param env - Environment variables to inspect (defaults to process.env)
* @returns `{ valid: true }` when DOCKER_HOST is absent or uses a unix socket;
* `{ valid: false, error: string }` for remote daemon schemes.
* @returns `{ valid: true }` when DOCKER_HOST is absent or points at the local
* socket; `{ valid: false, error: string }` otherwise.
*/
export function checkDockerHost(
env: Record<string, string | undefined> = process.env
Expand All @@ -920,7 +925,7 @@ export function checkDockerHost(
return { valid: true };
}

if (dockerHost.startsWith('unix://')) {
if (LOCAL_DOCKER_HOST_VALUES.has(dockerHost)) {
return { valid: true };
}

Expand Down
Loading