Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Connect to Local Beszel Agent in Docker #359

Closed
ericukk opened this issue Dec 31, 2024 · 4 comments
Closed

Unable to Connect to Local Beszel Agent in Docker #359

ericukk opened this issue Dec 31, 2024 · 4 comments
Labels
troubleshooting Maybe bug, maybe not

Comments

@ericukk
Copy link

ericukk commented Dec 31, 2024

I’m running into issues trying to connect to the local Beszel agent using the Docker setup provided in the getting started guide. Here is the relevant part of the docker-compose.yml I’m using:

services:
  beszel:
    image: henrygd/beszel:latest
    container_name: beszel
    restart: unless-stopped
    extra_hosts:
      - host.docker.internal:host-gateway
    ports:
      - 8090:8090
    volumes:
      - ./beszel_data:/beszel_data

  beszel-agent:
    image: henrygd/beszel-agent:latest
    container_name: beszel-agent
    restart: unless-stopped
    network_mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      PORT: 45876
      KEY: 'redacted'

After running docker compose down && docker compose up -d, the beszel-agent container is listed as “down,” and the logs don’t show any attempts to connect:

image

docker compose logs -f -n 100
beszel-agent  | 2024/12/31 23:08:27 INFO Root disk mountpoint=/ io=sda
beszel        | 2024/12/31 23:08:28 Server started at http://0.0.0.0:8090
beszel        | ├─ REST API:  http://0.0.0.0:8090/api/
beszel        | └─ Dashboard: http://0.0.0.0:8090/_/
beszel-agent  | 2024/12/31 23:08:27 INFO Detected network interface name=wlan0 sent=24551158 recv=25407343
beszel-agent  | 2024/12/31 23:08:27 INFO Detected network interface name=tailscale0 sent=26720 recv=58350
beszel-agent  | 2024/12/31 23:08:27 INFO Starting SSH server address=:45876

The beszel container is running fine, but I'm unable to figure out why the agent is not connecting. The agent logs don't show much info, and without shell access or nc inside the container, debugging is tricky.

Anyone have suggestions or insights into what might be causing this issue?

Beszel version 0.9.0
Raspberry Pi 4 on NixOS 24.11
cgroup memory is enabled

@henrygd
Copy link
Owner

henrygd commented Dec 31, 2024

Do you see errors on the logs page at /_/#/logs?

Scratch images are nice, but I agree it's annoying to debug something like this with no shell available. Maybe I'll add an :alpine image to make the process easier.

@henrygd henrygd added the troubleshooting Maybe bug, maybe not label Dec 31, 2024
@ericukk
Copy link
Author

ericukk commented Jan 1, 2025

Thanks for the quick response.
It seems that there was a connection problem when I tried to start it up the first time.

image

I just tried to compose down and up again but couldn't reproduce, there's only INFO logs of successful http requests.
I'll see if I can copy some tools into the container to try to get more information.

@ericukk
Copy link
Author

ericukk commented Jan 2, 2025

I believe I've figured out the issue and can now make it work. I recompiled the container using Alpine based on your suggestion, which was really helpful for debugging.

From the container, I could ping host.docker.internal and connect to other ports on my host, but not to 45876. After further debugging, I realized the issue was with the firewall. Once I opened it, everything worked.

I'll investigate why I didn’t need to do that when I tried to replicate on my Fedora setup, but only on NixOS. It might be due to some different default settings.

Thanks a lot for your help. I learned a great deal. Happy new year.

@ericukk ericukk closed this as completed Jan 2, 2025
@henrygd
Copy link
Owner

henrygd commented Jan 2, 2025

Interesting, thanks for the update!

I wonder if you would be able to connect from the host using telnet localhost 45876 with the firewall active, or if it's specifically a problem connecting from a container via host.docker.internal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting Maybe bug, maybe not
Projects
None yet
Development

No branches or pull requests

2 participants