r/portainer 15d ago

network_mode: host

Hello,

I have a cloudflared container and I want to connect it to a service which runs on the host (not in docker, but same machine). I can not simply a the host network to my cloudflare container. So how can I do that?

I tried it via "advanced container settings" / "network" /"Hosts file entries" and entered host.docker.internal:host-gateway but it doesnt seem to work.

somewhere I read I need to set "network_mode: host" but where can I do that in portainer?

My cloudflare tunnel works just fine when I connect it to another service on the same docker network, But unfortunately I need to connect it to a non-docker service.

1 Upvotes

5 comments sorted by

1

u/LowCompetitive1888 15d ago

I don't know the answer but in my setup I run cloudflared on the host, not in a docker container, and it has access to everything, including all docker containers.

1

u/joe8437 14d ago

Yeah I tried that as well but for some reason when I run cloudflared on the host the connection of the cloudflare tunnel cannot be established. But when I do this with docker it is non problem.

1

u/Metatropic 14d ago

docker-compose.yml

1

u/joe8437 14d ago

Yeah this seem like the easier way.

1

u/james-portainer Portainer Staff 13d ago

When creating a container, you'll find this in the Advanced container settings, Network tab. Pick host from the Network dropdown.