docker / docker/buildx

Neither modifing /etc/hosts nor adding '--add-host' flag worked for me

Open
#1,814 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status/triage
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

Contributing guidelines
I've found a bug and checked that ...
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem
Description

I modified the /etc/hosts file on my machine and changed the IP address of registry.my.example.com from 10.20.247.48 to 10.106.174.220, then I run "docker buildx build" command with '--add-host registry.my.example.com:10.106.174.220', but the modification seems not working.

Expected behaviour

the /etc/hosts file in the builder container should be like this:

10.106.174.220 registry.my.example.com
Actual behaviour

This is the output of sudo docker exec -t buildx_buildkit_zstd-builder0 cat /etc/hosts:

10.20.247.48 registry.my.example.com
Buildx version

github.com/docker/buildx v0.5.0-docker 780fad46f23e8d7c2d741d59144617aae5285b22

Docker info

No response

Builders list
NAME/NODE       DRIVER/ENDPOINT             STATUS   PLATFORMS
zstd-builder *  docker-container
  zstd-builder0 unix:///var/run/docker.sock running linux/amd64, linux/amd64/v2, linux/amd64/v3, 
                                                    linux/amd64/v4, linux/386
default         docker
  default       default                     running  linux/amd64, linux/386
Configuration

docker buildx create command:

sudo docker buildx create \
        --name zstd-builder \
        --driver docker-container \
        --driver-opt image=moby/buildkit:v0.10.3,network=host \
        --buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' \
        --use

docker buildx build command:

sudo docker buildx build --pull -t <some_image_name_with_tag> --add-host registry.my.example.com:10.106.174.220 \
            --file Dockerfile \
            --output type=image,name="registry.my.example.com/<some_image_name_with_tag>",oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true,push=true .
Build logs

No response

Additional info

No response

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

Start by reproducing the docker-container builder setup with the reported docker buildx create and buildx build commands, then inspect how the --add-host value is handled for that driver. Compare the builder container's /etc/hosts entry with the requested mapping and verify the behavior against the expected 10.106.174.220 address.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.