Skip to content

Add support for build-time extra_hosts for Version 3 #1293

Closed

Description

@kinnalru

It work well for Version 2.3 since docker/compose#5282 but invalid for Version 3

Activity

  1. anibalrivero commented on Oct 24, 2018

    @anibalrivero

    Is there a known workaround for this? Other than building the images outside of compose.

  2. kinnalru commented on Oct 25, 2018

    @kinnalru
    Author

    I'am using Version 2.3 for building images and other version for deploying.

  3. Stono commented on Jan 8, 2019

    @Stono

    Hi,
    Is there any update on this? It feels like a real omission from v3 when it is supported by the docker --add-host command.

    I really don't want to adjust our build process to building outside of compose, and I can't use version 2.3 because I lose support for other build aspects I need from 3?

    A work around to pass --add-host would be great?

  4. c5c86a commented on Feb 20, 2019

    @c5c86a

    For the following Dockerfile:

    FROM byrnedo/alpine-curl
    

    The following docker-compose.yml works (if you replace host and IP with your case):

    version:          '2.3'
    services:
      tmp:
        build:
          context:    .
          extra_hosts:
            - "host:IP"
        command:      -kIL https://host
        tty:          true
        stdin_open:   true
    

    But the following fails (if you replace host and IP with your case):

    version:          '3'
    services:
      tmp:
        build:
          context:    .
          extra_hosts:
            - "host:IP"
        command:      -kIL https://host
        tty:          true
        stdin_open:   true
    

    The error at docker-compose up is:

    The Compose file is invalid because:                                                                                                                                                 
    services.tmp.build contains unsupported option: 'extra_hosts' 
    
  5. posix4e commented on Sep 21, 2019

    @posix4e

    Any updates this would be very nice

  6. lmammino commented on Jan 21, 2020

    @lmammino

    Having this would be great. Currently doing weird hacks to circumvent this limitation... :(

  7. i3inc commented on May 21, 2020

    @i3inc

    is this on the radar as something to be fixed?

  8. ghevge commented on Jun 4, 2020

    @ghevge

    One more vote here for fixing this limitation. I was trying with 3.5 and the issue is still there

  9. thaJeztah commented on Jun 11, 2020

    @thaJeztah
    Member

    This was added to the compose 3.9 schema in #2517. The 3.9 schema is not yet released (will be together with the next 20.x release of docker), and will have to be implemented in docker-compose as well (as the docker CLI itself doesn't use the build section of compose files, and only uses docker-compose files for docker stack deploy).

    I'm closing this issue here, but subscribe / participate on docker/compose#7323 which is a ticket in the docker-compose repository for this

  10. dzieciou commented on Jan 23, 2022

    @dzieciou

    It's been almost a year and half and I can see this implemented. Any update on that?

  11. franchyze923 commented on Jan 30, 2024

    @franchyze923

    I'm running into this issue as well

  12. burka commented on May 14, 2024

    @burka

    It's solved in Version 3.9 #2517 - you can add extra_hosts: in build: and works for me. Maybe you need to update docker compose.

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