Container port closed to host

If I start a single-line python http server on my container (python -m http.server 8000), I’m able to visualize it on a browser from the host without issues.

But I actually want to visualise some stuff coming from a service that opens a different port (9944, specifically). When I try that, I can’t open on the host browser. Also nmap from the host shows the port as closed.

What sort of configuration do I need to do in order to get 9944 to show as open to my host?
I’ve been looking at port forwarding and NAT but doesn’t feel like the right direction, since I don’t care about how the port looks from outside my host.

Hi @bernardo,

You can access port 9944 on your container using a proxy device: Instance configuration - LXD documentation.

For example, with running a container c1 that has an IP address 192.0.2.1, you can add a new proxy device p1 with

lxc config device add c1 p1 proxy listen=tcp:127.0.0.1:9944 connect=tcp:192.0.2.1:9944

This will make 9944 on the container accessible over http via 9944 on the host. If you need to keep 9944 free on the host, you can change the port of the listen address.

Also because the proxy device (when running in its default non-nat mode) doesn’t actually need network connectivity between the host and the container, you can specify connect=tcp:127.0.0.1:9944 and this will still work and connect to the local-loopback address inside your container. This means you don’t have to worry about what the IP of your container is.