Closed adamlm closed 8 months ago
Thank you for this contribution! This patch doesn't seem to be specific to macOS, right? It should work on Linux and Windows as well, isn't it?
Thank you for this contribution! This patch doesn't seem to be specific to macOS, right? It should work on Linux and Windows as well, isn't it?
That's a good point. It works on Linux, but I don't have a Windows machine to test on. Getting it to work on Linux requires an extra step that we should probably document. The host.docker.internal
DNS entry does not get added to the container automatically with Docker Engine like it does for Docker Desktop.
I can add extra documentation for this. Where is the best place to add it? The Wiki seems to point to the ROS documentation for installation guides.
Description
This PR fixes a bug preventing
webots_ros2_driver
nodes running in a Docker image from launching and connecting to Webots running on a macOS host. The change set includes a newis_docker()
function that checks if the process is running in an image. If so, theget_host_ip()
will returnhost.docker.internal
, Docker's special DNS name that resolves to the host's IP address.Related Issues Closes #888
Affected Packages List of affected packages:
webots_ros2_driver
Tasks
Additional context I modeled the changes off the
is_wsl()
function; however, WSL has tighter integration with its host (Windows) than Docker Desktop. Docker and virtual machines seem like identical setups as far as this package is concerned.I am not intimately familiar with the
webots_ros2_driver
package, so feel free to suggest modifications if there are more appropriate places for these changes.