Docker networking question

Following the Single Server example I have:

docker container ls
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                  PORTS                                   NAMES
bee4e3e395d5   526214b8c3f8   "bash"                   58 seconds ago   Up 57 seconds           0.0.0.0:80->8080/tcp, :::80->8080/tcp   admiring_golick
7a00e9e9cca8   6a29263a9712   "docker-entrypoint.s…"   39 minutes ago   Up 39 minutes           6379/tcp                                agitated_curie
62b9417cafb4   mariadb:10.6   "docker-entrypoint.s…"   2 months ago     Up 13 hours (healthy)   3306/tcp                                mariadb-database

When I inspect the network:

"Containers": {
            "7a00e9e9cca8e7393fc413a980b352afe7edac470415cdda340a4f9983895224": {
                "Name": "agitated_curie",
                "EndpointID": "7e79f8d080c16973d67b760fc28203e5379fe222bc669beca45587bb8fea1167",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "bee4e3e395d5fa39ff7a528ec3173b31a87708c733afb6de0ddb105eb629ff35": {
                "Name": "admiring_golick",
                "EndpointID": "5f77c871b9656271f01fa0e25b65d564125453e9b32767b4a1c860c514a18eb7",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""

Attach to the frappe-bench container and ip -a reports

inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0

if I try to ping anything:

frappe@bee4e3e395d5:~/frappe-bench$ ping 1.1.1.1
bash: ping: command not found

Very new to Docker and must be missing something.

you just have 3 containers created. none of them seems to be serving frappe bench.

use native setup or you need to understand containers to use them in production.

to check network connection, wait-for-it is available.

Yes, docker is very different from VMs. The ideal image is one that is slimmed down to only include the bare necessities for the main process the container is running to function. Thus luxuries like ping are usually not installed.

If you need to do troubleshooting the network, you need to run a different container like one from the nicolaka/netshoot image in the original container’s network namespace, but needing to do this is rare.

Instead of ping, you could also try:

bench version
bench --help

And what’s in fact the problem you’re trying to solve?

docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
redis 6.2-alpine 6a29263a9712 6 weeks ago 27.5MB
frappe/erpnext v14.30.6 526214b8c3f8 6 weeks ago 1.6GB
mariadb 10.6 6d86fc66ebd1 2 months ago 380MB

I started frappe-erpnext

docker run -dit -p 80:8080 526214b8c3f8 bash

docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bee4e3e395d5 526214b8c3f8 “bash” 2 hours ago Up 2 hours 0.0.0.0:80->8080/tcp, :::80->8080/tcp admiring_golick
7a00e9e9cca8 6a29263a9712 “docker-entrypoint.s…” 3 hours ago Up 3 hours 6379/tcp agitated_curie
62b9417cafb4 mariadb:10.6 “docker-entrypoint.s…” 2 months ago Up 16 hours (healthy) 3306/tcp mariadb-database

Attach to the container:

docker attach admiring_golick

frappe@bee4e3e395d5:~/frappe-bench$ bench version
erpnext 14.33.2
frappe 14.43.1

@Peer I’m trying to use curl on the host to see if the frappe interface can be accessed like so:

curl 172.17.0.2:8080
curl: (7) Failed to connect to 172.17.0.2 port 8080: Connection refused

@revant_one i will use the --name flag in the future, my apologies (and many thanks).

@smino, you will not get the frappe web interface this way just starting up a container from the frappe/erpnext image. The only service you could use curl with on that is the werkzeug server on port 8000/tcp.

Instead, you will need to have all the services running together in a docker compose. Then you can curl the frontend container’s nginx at 8080/tcp. See Single Server Example for more info on how to get started on that.

1 Like

I can’t help because for this case, Single Server example starts 2 random named containers and a mariadb container somehow.

Again, this is a learning experience for me and your help is greatly appreciated.

I skipped Traefik for this exercise and have three containers: frappe, redis and mariadb, their names were generated automatically except for the frappe one.

docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
325b3dfeee25 526214b8c3f8 “bash” 24 hours ago Up 24 hours 0.0.0.0:80->8080/tcp, :::80->8080/tcp frappe
7a00e9e9cca8 6a29263a9712 “docker-entrypoint.s…” 34 hours ago Up 34 hours 6379/tcp agitated_curie
62b9417cafb4 mariadb:10.6 “docker-entrypoint.s…” 2 months ago Up 46 hours (healthy) 3306/tcp mariadb-database

docker exec -it agitated_curie ps -a
PID USER TIME COMMAND
1 redis 1:47 redis-server *:6379
35 root 0:00 ps -a

docker top mariadb-database
UID PID PPID C STIME TTY TIME CMD
systemd+ 3091 3069 0 Sep22 ? 00:00:56 mariadbd --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --skip-character-set-client-handshake --skip-innodb-read-only-compressed

docker top frappe
UID PID PPID C STIME TTY TIME CMD
opc 1584283 1584261 0 Sep22 pts/0 00:00:00 bash
opc 1718189 1584261 0 01:16 ? 00:00:00 /home/frappe/frappe-bench/env/bin/python -m frappe.utils.bench_helper frappe serve
opc 1718217 1718189 7 01:16 ? 01:38:28 /home/frappe/frappe-bench/env/bin/python -m frappe.utils.bench_helper frappe serve
opc 2611402 1584283 0 13:37 ? 00:00:00 nginx: master process /usr/sbin/nginx
opc 2611403 2611402 0 13:37 ? 00:00:00 nginx: worker process
opc 2611404 2611402 0 13:37 ? 00:00:00 nginx: worker process

A few debugging things I’ve tried to see if the containers are running:

docker exec -it mariadb-database mysql
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)

docker exec -e “TERM=xterm” -it frappe service nginx status
nginx is running.

This is not urgent or a production environment and can be scrapped and started from scratch at any time. I’m wondering if it is simply inter-container or host to container networking that is the problem.

I think what @revant_one was getting at was that if you follow the Single Server example, you would have a docker compose file that spins up about 13 containers. If you skip traefik (which is fine) then 12 containers. After the configurator finishes its job, it shuts down which would leave 11. But you only have 3. So something isn’t right there. And the containers would have been automatically named something like frappe_docker-frontend-1, frappe_docker-db-1, etc. as opposed to the random names you are getting by trying to spin them up with docker run.

If you follow the guide exactly, step by step, you will end up with (1) a docker-compose.yml file, (2) a completely functional (but unconfigured) erpnext “server”, (3) a frontend you can access with your web browser, and you will also have (4) something that can be properly troubleshot if there are problems.

I learned how to run ERPNext via docker thanks to learning through that guide, and I’m sure I’m not the only one, so feel free to ask any questions about it and someone will be able to answer.

1 Like

After a re-do, I’ve managed to get things a little closer to as they should be:

docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ba109ff30c96 frappe/erpnext:v14.30.6 “nginx-entrypoint.sh” About an hour ago Up About an hour erpnext-one-frontend-1
914395cfaa63 frappe/erpnext:v14.30.6 “bench worker --queu…” About an hour ago Up About an hour erpnext-one-queue-long-1
18ca4ad518bc frappe/erpnext:v14.30.6 “bench schedule” About an hour ago Up About an hour erpnext-one-scheduler-1
cd855ece0afe frappe/erpnext:v14.30.6 “/home/frappe/frappe…” About an hour ago Up About an hour erpnext-one-backend-1
a0c3b8315c8f frappe/erpnext:v14.30.6 “bench worker --queu…” About an hour ago Up About an hour erpnext-one-queue-default-1
f8606f9dbbf7 frappe/erpnext:v14.30.6 “node /home/frappe/f…” About an hour ago Up About an hour erpnext-one-websocket-1
452f302f21e5 frappe/erpnext:v14.30.6 “bench worker --queu…” About an hour ago Up About an hour erpnext-one-queue-short-1
2015a429cb33 redis:6.2-alpine “docker-entrypoint.s…” About an hour ago Up About an hour 6379/tcp erpnext-one-redis-queue-1
94c11e797f61 redis:6.2-alpine “docker-entrypoint.s…” About an hour ago Up About an hour 6379/tcp erpnext-one-redis-cache-1
76c572e6ccb5 redis:6.2-alpine “docker-entrypoint.s…” About an hour ago Up About an hour 6379/tcp erpnext-one-redis-socketio-1
966a897c9b99 mariadb:10.6 “docker-entrypoint.s…” About an hour ago Up About an hour (healthy) 3306/tcp mariadb-database

Not sure where I would find the web interface on the frontend or if its not configured correctly:

docker compose --project-name erpnext-one exec frontend ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
204: eth0@if205: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:13:00:0b brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.19.0.11/16 brd 172.19.255.255 scope global eth0

docker compose --project-name erpnext-one exec frontend curl localhost:8080
<!doctype html>

404 Not Found

Not Found

localhost does not exist

  1. Site should exists to be served. It’s created by bench new-site --no-mariadb-socket ... command.
  2. Frappe searches for site name directories in sites directory. It picks sites from host header. E.g. curl -H "Host:site1.com" localhost:8080

EDIT: After a site reinstall and backend container restart the curl -H command returns a webpage. Forwarding it to the host environment will be next.

Does one issue bench commands in the frontend or backend ? For example:

docker compose --project-name erpnext-one exec frontend bench
–site one.example.com mariadb
ERROR 2005 (HY000): Unknown server host ‘mariadb-database’ (-2)

docker compose --project-name erpnext-one exec backend bench -
-site one.example.com mariadb
ERROR 1045 (28000): Access denied for user ‘_b5c7cfc26b1ff210’@‘172.18.0.11’ (using password: YES)

At this point how would one apply changes to files like site_config.json etc.