Docker network configuration

Hello

I’m trying to install the Docker images of both ERPNext (single production with env-local) and n8n (Docker) on a single local machine. Both installations succeed and both are accessible with http://mysite.localhost and http://localhost:5678 respectively.

The problem I have is how do I configure Docker networking so that I can establish communication in both directions between the 2 applications. I have absolutely no experience in Docker so any guidance as to what to search for and how to go about resolving this would be much appreciated.

Generally all docker containers are networked together if it on the same machine unless you make some custom subnet masks for each.
What you can do is open the interactive shell/bash of the container and find the ip addr of the system. Do the same for the other system and then connect it as you want to. Below link tells how to do it
https://phase2.github.io/devtools/common-tasks/ssh-into-a-container/

Docker generally have a default network to which it connects the container even if you haven’t specified it. In case you want to make a new network yourself Im sure this guide might help you.

Also some screenshots would be more helpful in getting to know the exact thing you are asking for.

Again if you can’t get to the bash terminal there are a lot of networking aide related containers. If there is a problem with these, just message here and Im sure I can find a container that helps with networking with other containers.

1 Like

If this needs to be setup in production with certificates, you will need some loadbalancer type service that manages certificates for domains and maps them to containers running on server.

this service will be your main service exposing ports 443 and 80, now any other service that needed these ports will need to be reverse proxy using the primary loadbalancer service.

for simple docker compose based setup try https://nginxproxymanager.com. I think this is suitable for your current case. Last time I checked it cannot be installed in a swarm mode.

for docker swarm try https://traefik.io. TLDR at https://dockerswarm.rocks

If this is for local setup, just map ports without any conflict. To connect to service running on docker host use ip 172.17.0.1 instead of using localhost or 127.0.0.1

1 Like

for future visitors it was solved with:

  1. create docker overlay network
  2. run n8n with docker-compose and attach that to the overlay network
  3. run erpnext dev setup [1] with docker-compose and attach that to the same overlay network

all containers are then running on the same network and can interact with each other via host names (e.g. n8n / frappe / etc.)

we tried [2] for local dev, but that doesn’t expose anything via port 8000 as it gets proxied by traefik/nginx. for some reason exposing port 8000 on the erpnext-python container works if you curl it outside the container (e.g. mysite.localhost:8000) but as soon as you try to do it from n8n (e.g. http://erpnext-container-ip:8000 or http://erpnext-python:8000) to erpnext it fails.

for production, we are using traefik as a reverse proxy that forwards the request to either n8n or erpnext. traefik also takes care of cert renewal/etc.

[1] frappe_docker/development at main · frappe/frappe_docker · GitHub
[2] https://github.com/frappe/frappe_docker/blob/main/docs/single-bench.md

2 Likes