Skip to content

Docker-compose add-host option #6355

Closed
Closed

Description

@nlapshin

There is an option 'add-host' in docker, it allows to add hostname exactly during container assembly. Is there an implementation of this option for docker-compose?

I've seen the this question was discussed in issue #5282 But it is closed and there is no practical sample that works.

Activity

  1. nlapshin commented on Nov 20, 2018

    @nlapshin
    Author

    https://docs.docker.com/compose/compose-file/#extra_hosts

    Thanks for answer. I have tried this option. But, if I understand correctly, 'extra_hosts' added hostname after container run.

    In my case I need to use hostname during container assembly. I use docker-compose version 3.7.

    This is example for docker.

    docker build --add-host=docker:10.180.0.1

    But, this example for docker-compose(with 'extra_hosts' option in the config)

    docker-compose build

    These examples don't work identically. In the case of the docker example, I can use additional hostname, but, in the case of the docker-compose exampe, I cannot use it.

  2. shin- commented on Nov 20, 2018

    @shin-
  3. nlapshin commented on Nov 20, 2018

    @nlapshin
    Author

    Thanks a lot!

  4. burka commented on May 14, 2024

    @burka

    For anyone searching like me: It's solved in Version 3.9 docker/cli#2517 - you can add extra_hosts: in build: now.

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