docker / docker/cli

CLI does not fill NetworkAttachmentConfig.Target correctly

Open
#391 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/networking area/swarm kind/bug
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

The CLI used to put whatever reference to a network the user entered directly into NetworkAttachmentConfig.Target. This field is documented to only contain a network ID, so this was the wrong behavior. It turned out that the daemon was automatically rewriting these names into IDs, which is bad because the daemon shouldn't be modifying the spec supplied by the user. The CLI behavior was fixed as part of https://github.com/moby/moby/pull/32062, and there was a lot of discussion about this in the PR:

https://github.com/moby/moby/pull/32062#discussion_r108245707
https://github.com/moby/moby/pull/32062#discussion_r110199017
https://github.com/moby/moby/pull/32062#issuecomment-292242071

The daemon still rewrites names into IDs for backward compatibility, but this code path isn't meant to be used going forward, and ideally should only be enabled for older API versions.

The CLI's behavior appears to have regressed in #62. It's no longer using the ID as it should. The problem is hidden by the magic rewriting in the daemon.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the behavior discussed in PR #32062 and the regression described in issue #62, then trace where the CLI constructs NetworkAttachmentConfig.Target. Confirm the CLI supplies a network ID rather than a name, and add or update coverage for that behavior if the relevant test location is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.