Skip to content

Add support for build-time extra_hosts #5282

Closed

Description

@clery

I'm having an issue with extra_hosts on compose.

$> docker -v               
Docker version 17.06.0-ce, build 02c1d87
$> docker-compose -v 
docker-compose version 1.16.1, build 6d1ac219

The --add-host option works correctly with docker build but the extra_hosts of docker-compose doesn't.
I'm using a 3.3 version ok Compose file, here is a sample

version: '3.3'

services:
  my_service:
    build:
      context: ./some_folder
      args:
        ARG1: $ARG1
        ARG2: $ARG2
    extra_hosts:
      - "my.local.network.url:XXX.XXX.XXX.XXX"
    environment:
      SOME_VAR: $SOME_VAR
    volumes:
      - ./folder1:/folder1

My volumes are not interfering with /etc/hosts or anything like that.
Can anyone tell me if I'm doing anything wrong ?

Activity

  1. shin- commented on Oct 18, 2017

    @shin-

    This is working as intended – the extra_hosts field is runtime configuration for your service, it doesn't affect builds.

  2. clery commented on Oct 18, 2017

    @clery
    Author

    I see, my bad then. Can you tell me how I am supposed to reproduce the behaviour of docker build --add-host with docker compose then ?

  3. shin- commented on Oct 18, 2017

    @shin-

    Unfortunately, that feature hasn't yet been implemented in Compose.

  4. clery commented on Oct 19, 2017

    @clery
    Author

    Well, that's inconvenient !

    Thanks for your time anyway :)

  5. ravn commented on Oct 25, 2017

    @ravn

    @shin- is there an open issue for implementing extra_hosts at build time?

  6. reopened this on Oct 25, 2017
  7. shin- commented on Oct 25, 2017

    @shin-

    Well there's this one :)

  8. ravn commented on Oct 25, 2017

    @ravn

    I spent two hours this afternoon trying to get that to work, while sorting out that it was not my usage nor my installation (which I just updated to Ubuntu 17.10 with several old versions of docker-compose) that was the problem. The actual thing I want to solve is to facilitate Maven (we do Java) to access a caching proxy running on the host to avoid downloading half the internet every time an image needs to be rebuild. I need a reliable mechanism to refer to the host and thought this might work. I am relatively new to Docker so there might be a trick I have overlooked? I need this to work on Mac and Linux for now, and Windows in the long run.

  9. added this to the 1.18.0 milestone on Oct 25, 2017
  10. changed the title [-]Extra_hosts not working[/-] [+]Add support for build-time extra_hosts[/+] on Oct 26, 2017
  11. kinnalru commented on Apr 19, 2018

    @kinnalru

    @shin- there is no such option in version 3 config file. Why?

  12. greyblake commented on Jul 16, 2018

    @greyblake

    Does someone know some work arounds for this?

  13. momovuk commented on Jul 27, 2018

    @momovuk

    Is there any news in this regards? When the extra_hosts will finally add the values to /etc/hosts, it would be highly appreciated!

  14. kinnalru commented on Aug 15, 2018

    @kinnalru

    I open new issue #6138

  15. kinnalru commented on Aug 16, 2018

    @kinnalru
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions