j-tim / connect-docker-host-from-docker-container-example

Simple example project that explains how connect to the Docker host from within a Docker container
18 stars 6 forks source link

use without docker desktop (docker engine ) #1

Open cirolosapio-accenture opened 1 year ago

cirolosapio-accenture commented 1 year ago

hi i've used this confiugration a lot with docker desktop but when i switched from docker desktop to docker engine i cannot connect to host from container anymore

do you find any solution?

j-tim commented 1 year ago

Hi @cirolosapio-accenture, With Docker desktop, this should work out of the box without adding the --add-host=host.docker.internal:host-gateway flag.

I assume you switched from Docker Desktop on eighter Mac of Windows to Docker engine on a Linux system, right? In that case, your need to add the flag.

cirolosapio-accenture commented 1 year ago

yes i've installed docker engine + compose on wsl but unfortunately this flag is not enough i'm not able to see the host from the container

j-tim commented 1 year ago

Ok so you are using the Windows Subsystem for Linux (WSL) and the Docker engine without using Docker desktop on Windows. To be honest I don't have experience with these kind of setups. Don't you have the option to use run the Docker engine using Linux and skip the whole Windows part?

If you can't, do you need to enable some firewall settings in Windows? This blogpost might be interesting to read: https://medium.com/@frcs6b/wsl2-docker-without-desktop-communicate-with-windows-host-92daf9cf73cd

cirolosapio-accenture commented 1 year ago

Don't you have the option to use run the Docker engine using Linux and skip the whole Windows part?

what do you mean with "Windows part"? i've installed the docker engine on wsl following the guide for linux and it works

the last problem remain to be able to see windows/wsl host from the container

If you can't, do you need to enable some firewall settings in Windows? This blogpost might be interesting to read: https://medium.com/@frcs6b/wsl2-docker-without-desktop-communicate-with-windows-host-92daf9cf73cd

i've read and after some tests i'm not able to see windows/wsl

j-tim commented 1 year ago

Thanks for your response. To be honest i still don’t exactly understand what you try to do.

Do have a small example repository to reproduce the issue? Otherwise maybe create an issue on the Docker project.

I dont’t have experience with Windows subsystem for Linux.

cirolosapio-accenture commented 1 year ago

yes this one

i have a php container and i'm trying to debug it with xdebug from vscode this require that the php container can comunicate with windows/wsl host (where i run the debug server)

until a few months ago i was able to debug with docker desktop now i switched from docker-desktop to docker-engine only and the same configuration does not work anymore

desktop vs engine