Skip to content

Support extra_hosts in _CLIBuilder #7323

Closed

Description

@tomaszzielinski

Is your feature request related to a problem? Please describe.

I'm using v2.4 yml as I need to pass extra_hosts to the builder and v3 doesn't seem to support that (yet). I'm evaluating using docker-compose with BuildKit but it seems that extra_hosts are not propagated all the way to the Docker CLI [1].

[1] https://github.com/docker/compose/blob/1.26.0-rc3/compose/service.py#L1790-L1802

Describe the solution you'd like

It would be great if _CLIBuilder made use of extra_hosts, as they seem to be properly passed down to it [2].

[2] https://github.com/docker/compose/blob/1.26.0-rc3/compose/service.py#L1085-L1100

Describe alternatives you've considered

I tried mounting my own hosts file on top of /etc/hosts but it doesn't seem to be possible inside a "normal" (i.e. unpriviledged, etc.) container.

I also thought about patching docker-compose locally & maintaining a fork, but it doesn't really make sense given that the default (non-CLI) builder works correctly and that I don't stricly need BuildKit (it was meant to be a nice bonus).

Activity

  1. skokhanovskiy commented on May 9, 2020

    @skokhanovskiy

    Faced with same bug. I think that person who added extra_hosts support just forgot about existence of cli builder. So. that probably should be a bug.

    Now I can't use buildkit because in my dockerfile there are images from intranet registry. The hostname of this registry are not resolving by google public dns.

  2. skokhanovskiy commented on May 9, 2020

    @skokhanovskiy

    So, i fixed issue with unavailable intranet DNS servers by using dnsmasq on the docker0 interface as dedicated DNS server for docker daemon.

    Any way, I found that there are another unrealized command-line parameters:

    This options above are not working if they are specified in a docker-conpose file and docker-compose build start with the COMPOSE_DOCKER_CLI_BUILD=1 environment variable.

  3. thaJeztah commented on May 10, 2020

    @thaJeztah
    Member

    Yes, not all options were added in the first implementation of the "cli" based build (also see #6584 (comment)). I think it makes sense to add this though, so contributions welcome.

    That said, I think this option can be added to the v3 schema as well, to bring parity with v2. This option is already supported by both the "classic" and BuildKit builders, so I don't see a reason for not adding it.

  4. thaJeztah commented on May 10, 2020

    @thaJeztah
    Member

    opened docker/cli#2517 - if that's accepted, this can be implemented in compose when support for the 3.9 schema is added

  5. syabro commented on May 11, 2020

    @syabro

    @thaJeztah docker/cli#2517 is merged. What's next here? :)

  6. syabro commented on Aug 27, 2020

    @syabro

    @thaJeztah any news?

  7. thaJeztah commented on Aug 27, 2020

    @thaJeztah
    Member

    Not sure; there's changes merged in this repository to support the "unified" schema (https://github.com/compose-spec/compose-spec), so perhaps it's supported own the latest version

    @aiordache do you know?

  8. dzieciou commented on Jan 23, 2022

    @dzieciou

    It's been a year and half since last update. Any news on that?

  9. ndeloof commented on Jan 24, 2022

    @ndeloof
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions