moby / moby/libnetwork

`extraHosts` with `useDefaultSandbox` results in /etc/hosts being replaced rather than updated

Open
#2,294 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
875
PR merge metrics
No merged PRs in 30d

Description

In docker terms, using the --add-hosts flag with the --net=host flag results in the /etc/hosts having only the --add-hosts lines. The content from the machine's /etc/hosts is not present.

I believe this is in part due to changes in PR#2232 (though the behavior before might have been that --add-hosts was silently ignored, which is probably more incorrect).

In sandbox_dns_unix.go:84, we skip over the block to copy from originHostsPath if extraHosts is non-empty.

Contributor guide

No contributing guide indexed for this repository

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

Start in sandbox_dns_unix.go around line 84 and trace how originHostsPath and extraHosts are handled when useDefaultSandbox is enabled. Reproduce the --add-hosts and --net=host combination, then verify that the machine's /etc/hosts content remains present alongside the added host entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.