My docker container runs an application which needs to connect to a websocket server running on the host.
Docker is in rootless mode to launch the docker service on a non-sudoer user account.
I did not find any way to ping the host from the container...
Any suggestion ?
Host OS: ubuntu 20.04 Container OS: ubuntu 20.04 docker version: 24.0.5
I read https://docs.docker.com/engine/security/rootless/
Adding -p PORT_ON_HOST:PORT_IN_CONTAINER does not work because the PORT_ON_HOST is already used by the websocket server.
For now I use this work around: docker service is launched as root at boot and the non-sudoer user can run containers on this docker service. But I really would like to run a rootless docker daemon for security reasons.
Docker 26 added the environment variable DOCKERD_ROOTLESS_ROOTLESSKIT_DISABLE_HOST_LOOPBACK=false which allows a rootless container to connect to a service running on host: https://docs.docker.com/engine/release-notes/26.0/#new
I still do not find any way to ping the host from the rootless container...
BUT the rootless container connects successfully to the websocket service running on the host identified by ip address 10.0.2.2.