Docker Community Forums

Share and learn in the Docker community.

Accessing host machine from within docker container

What if your docker works with linux?

Docker Container to access host ports =>

1 Like

This worked ! Thank you

Yes, same issue here and a valid use case.

As per this page you can also use host.docker.internal as a platform-agnostic way to reference the host.

1 Like

I thought you were going to be my hero… but as per the very next sentence on that page,

This is for development purpose and will not work in a production environment outside of Docker for Windows.

EDIT: I see the same comment in the Mac docs saying the same thing, all as of 18.03, however I have 18.07 and that does not resolve.

Can you use environment variables for that matter? You can write any host information (the host ip) in a variable and pass it to the container the moment you run it.

Yes, check this post.

thank you ! you saved my week <3

My situation is to use the host HTTP Proxy in order to access the outer network for the build task.

Aside, for Linux this seems to require --add-host=host.docker.internal:host-gateway. Or use instead of host.docker.internal.