You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
shin- commentedon Nov 20, 2018
https://docs.docker.com/compose/compose-file/#extra_hosts
nlapshin commentedon Nov 20, 2018
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.
But, this example for docker-compose(with 'extra_hosts' option in the config)
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.
shin- commentedon Nov 20, 2018
You can use
extra_hostsin thebuildsection of your config definition, but only with v2 Compose files.If you're set on using v3, you'll want to follow this issue instead: docker/cli#1293
nlapshin commentedon Nov 20, 2018
Thanks a lot!
Compose > Compose-file > 'extra_hosts' > buildtime/runtime documentation
burka commentedon May 14, 2024
For anyone searching like me: It's solved in Version 3.9 docker/cli#2517 - you can add
extra_hosts:inbuild:now.