How to connect to a server running on docker host from a container in rootless mode?

174 Views Asked by At

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.

0

There are 0 best solutions below