-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set DOCKER_HOST_IP environment variable automatically #2915
Comments
@msabramo Not exactly what you're asking for, but could you perhaps do something like the following?
|
@sudarkoff Thanks! That would be pretty cool. Unfortunately, docker-compose doesn't support fancy interpolations.
|
Gotcha, makes sense. Then I'd vote for just adding another line to the
|
Yeah I came to the same conclusion. This should be addressed in docker-machine; not docker-compose |
This is useful because it can be used in `docker-compose.yml` to make a container's external port bind to the Docker host's public IP address. See: docker/compose#2915 (comment)
This is useful because it can be used in `docker-compose.yml` to make a container's external port bind to the Docker host's public IP address. See: docker/compose#2915 (comment) Signed-off-by: Marc Abramowitz <[email protected]>
|
This is useful because it can be used in `docker-compose.yml` to make a container's external port bind to the Docker host's public IP address. See: docker/compose#2915 (comment) Signed-off-by: Marc Abramowitz <[email protected]>
Reopened this because docker/machine#3057 was closed and so wondering if it might make sense to do something in docker-compose since it was deemed to be out of scope for docker-machine. |
It still feels like this is more appropriate for |
@dnephin: I agree that docker-machine seems like the better place to solve this. Thanks for chiming in! |
@msabramo how should i set export DOCKER_HOST_IP in default env. I am not able to do |
What I've been doing lately is using direnv with the following line in my
Could also use something like:
|
I find it weird that I cannot do something like |
My use case is that I'm running docker-compose on a Mac so when I do
docker-compose port
, by default it returns0.0.0.0
as the IP address, which is not useful if you're on a Mac and trying to contact a service on the Docker host.Example:
I have a
docker-compose.yml
that looks like this:Now I do:
Connecting to
0.0.0.0:32777
of course from the Mac is not useful.So instead I'd like to use make the container bind to the real IP address of the Docker machine. I change my
docker-compose.yml
to the following:This in itself accomplishes nothing because
DOCKER_HOST_IP
is not set:It works great if I arrange for
DOCKER_HOST_IP
to be set.One nice way to do this is with direnv. Assuming I have direnv installed, I can do this:
Now I get this:
Beautiful!
But now if I want my little docker-compose project to be easily usable by others, I have to tell them to install direnv. Also my solution assumes folks are using
docker-machine
and maybe they aren't. Maybe they are using straight Docker without Docker Machine and so thatdocker-machine ip
command won't work.I am asking if
docker-compose
could simply set that environment variable automatically, perhaps by taking the existingDOCKER_HOST
variable and massaging it into a simple IP address.Then it just works out of the box without requiring direnv.
Reasonable?
Cc: @sudarkoff
The text was updated successfully, but these errors were encountered: