Access Docker Erpnext from other machines on local network

Hello There!

I installed Erpnext in a docker container. It runs locally @ https://gestionale.localhost. Now I’m trying to connect to it from other machines on my local network (both cable and wifi) with no success.

I did a little research and ran a docker network inspect erpnext-one command (where erpnext-one is the name of my container).

It yielded this:

[
    {
        "Name": "erpnext-one",
        "Id": "58c0b3c5462d8e2fcf583263b0c86d544ef23409ae53b6a560b86a37ee636db8",
        "Created": "2022-06-14T17:42:36.5909447Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.21.0.0/16",
                    "Gateway": "172.21.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "86380925f7ceecb40e7414b1e9450c48ba11f3ebe6f727a246f700504a71baed": {
                "Name": "erpnext-one-frontend-1",
                "EndpointID": "9bfe93d3ecc1d56155bec6c93a07539fcd581787e137e27e122ae6e4c8a5c8ab",
                "MacAddress": "02:42:ac:15:00:02",
                "IPv4Address": "172.21.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "bench-network",
            "com.docker.compose.project": "erpnext-one",
            "com.docker.compose.version": "2.6.0"
        }
    }
]

So I know my container is running in bridge mode. Even though I’m not too confident with the whole concept of docker network drivers I guess this means the container has its own IP address rather than what would happen in host mode where it would be using the IP address of the machine it runs on.

Now, if I try to connect to 172.21.0.2 though, from either the machine running erpnext or any other machine on the network, I don’t get anywhere.

What am I missing? How do I connect to the container from another machine on the local network? And how do I connect to the container from the machine running it using an IP address rather than a URL?

I’m pretty new to docker, hope I’m not missing something too obvious.

TIA

EDIT: Running on Win, but installed through WSL bridged to Docker Desktop for the sake of simplicity, if it’s by any means useful

I can’t help much on Windows.

  • If site is available from local machine and you get 404 from any other machine? then you can access the machine already you just need to configure.
  • If site is only available from local machine and other machines on lan don’t even see 404 page then first try to get to a state where all machines can ping port 80/443 of machine running containers.

To configure correct Frappe Site Name / Host, add sitename.localhost to /etc/hosts of all your machines.

Or setup a local DNS server and connect to that from all machines instead of ISP dns and configure DNS for sitename.localhost.

if it is single site, single bench setup refer frappe_docker/pwd.yml for setting default site for bench. In that case as long as you can reach port 8080 it will serve default site and no need to setup /etc/hosts or dns server.

How would I go about figuring out even just the IP address and port to access erpnext on the local machine? That by itself might give me a little insight maybe…
'Cause I access erpnext through a URL and it works, but that’s pretty much as far as I can get

  • Connecting to the machine’s LAN IP address (192.168.0.130) on port 80 i get 404, both from the machine and other machines (I guess that’s nginx!).
  • Same thing on port 8080 no connection in all cases
  • Connecting to the WSL LAN IP (172.25.32.1) address on port 80 I get 404 when connecting from the machine itself and no connection when connecting from other local machines
  • Same thing on port 8080 no connection in all cases

I suppose case 1 give some hope. How would I go about configuring?

Can you add following to machine’s /etc/hosts. Machine which is trying to connect to 192.168.0.130.

192.168.0.130    gestionale.localhost

In case of windows check this /etc/hosts on Windows · GitHub

file is generally located at c:\Windows\System32\Drivers\etc\hosts

Then connect to the site with http://gestionale.localhost

Yep, did that, and it’s “working” in the sense that now going to http://gestionale.localhost returns a 404 on my network’s machines, as going to the IP address does on the local machine.

I stopped the container to rule out that 404 wasn’t served by anybody else, and that was confirmed. So I guess I’ll have to do something with nginx now in order to get the interface served instead of a 404, right? Or is it about exposing the ports to the outside world from some config in docker?

try chaning the FRAPPE_SITE_NAME_HEADER environment variable in your erpnext-one.yaml. under the frontend service.

Change it from $$host to gestionale.localhost, update the project (docker compose ... up ...)

then try to access from LAN?

It didn’t change anything by itself BUT it did get working after I changed that and added a

ports:
  - "8080:8080"

in the erpnext-one.yaml file. Adding just the ports gave a better looking 404 (text slightly formatted, as opposed to the previous one which was basically a monospace 404 not found).
So now I head to the local machine’s local network IP address on port 8080 and get the interface served with no issue :slight_smile:

I’ll mark this post as Solution, since it eventually got working.

Just out of curiosity: what is $$host supposed to hold?

Thanks again for the help, it was crucial in getting things working!

read more about host here Module ngx_http_core_module

It is used in nginx config to override X-Frappe-Site-Name header frappe_docker/images/nginx/nginx-template.conf at 45ff41d8bc13f3037e44b88ec8131c20565e5858 · frappe/frappe_docker · GitHub

This header is used to serve site for the incoming request. frappe/frappe/app.py at f7e00633b935951829d05f48cd831a135b66716d · frappe/frappe · GitHub