DOCKER_CONFIG env var is parsed inconsistently and incorrectly in fromDockerConfig / fromDockerContext
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, typescript
- Domain
- devops
Research direction
Start in lib/docker-client.ts at fromDockerConfig and fromDockerContext, then trace how each entry point resolves DOCKER_CONFIG and the default home-directory path. Done means both entry points use the Docker config directory consistently, including config.json and contexts paths, while preserving behavior when DOCKER_CONFIG is unset.
Written by the indexing model from the issue text.
Description
DOCKER_CONFIG is the path to Docker's config directory (default ~/.docker), but docker-client.ts interprets it two different ways, and neither matches that.
1. fromDockerConfig treats it as the path to config.json
const configPath =
process.env.DOCKER_CONFIG ||
join(homedir(), '.docker', 'config.json');
With DOCKER_CONFIG=/etc/docker-config, this does readFile('/etc/docker-config', 'utf8') on a directory, which fails with EISDIR. That is not ENOENT, so the "config file doesn't exist, use default" branch below doesn't catch it either — the error propagates and fromDockerConfig() throws instead of connecting. It should be join(configDir, 'config.json').
2. fromDockerContext treats it as a directory, then appends .docker
const configDir = process.env.DOCKER_CONFIG || homedir();
const contextsDir = join(configDir, '.docker', 'contexts', 'meta');
const tlsDir = join(configDir, '.docker', 'contexts', 'tls');
The .docker component is only correct for the homedir() fallback. With DOCKER_CONFIG=/etc/docker-config this looks in /etc/docker-config/.docker/contexts/meta rather than /etc/docker-config/contexts/meta, so context lookup fails with Docker contexts directory not found.
The two readings are mutually inconsistent — at most one could be right for a given value of the variable.
Expected
Both should resolve the config directory the same way, e.g.
const configDir = process.env.DOCKER_CONFIG || join(homedir(), '.docker');
// config.json -> join(configDir, 'config.json')
// contexts -> join(configDir, 'contexts', 'meta') / join(configDir, 'contexts', 'tls')
This matches the CLI: https://docs.docker.com/reference/cli/docker/#environment-variables
Notes
Neither path misbehaves when DOCKER_CONFIG is unset, which is presumably why it hasn't come up. Affects main as of a4d3867.
Found while adapting the connection logic in docker-client.ts for another client; I haven't opened a PR. This report was written by Claude (AI-generated) and reviewed by me before filing.
- Dominant language
- TypeScript
- Stars
- 107
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from docker/node-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
-
Podman compatibility Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100