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 ?
This is working as intended – the extra_hosts
field is runtime configuration for your service, it doesn't affect builds.
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 ?
Unfortunately, that feature hasn't yet been implemented in Compose.
Well, that's inconvenient !
Thanks for your time anyway :)
@shin- is there an open issue for implementing extra_hosts at build time?
Well there's this one :)
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.
@shin- there is no such option in version 3 config file. Why?
Does someone know some work arounds for this?
Is there any news in this regards? When the extra_hosts will finally add the values to /etc/hosts, it would be highly appreciated!
I open new issue #6138
Issue moved to https://github.com/docker/cli repo
Most helpful comment
Is there any news in this regards? When the extra_hosts will finally add the values to /etc/hosts, it would be highly appreciated!