Issue with running a safe ipv4 root node inside a podman container: Failed to bind UDP socket

A root node I cannot even start when I set the public address.

$ podman logs test_rootnode-ipv4
Starting logging to stdout
Error:
   0: Cannot start node (log path: unknown). If this is the first node on the network pass the local address to be used using --first

   1: Routing error:: Cannot connect to the endpoint: Failed to bind UDP socket
   2: Cannot connect to the endpoint: Failed to bind UDP socket
   3: Failed to bind UDP socket
   4:
Address not available (os error 99)

Location:
   sn/src/bin/sn_node.rs:216

Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

status

$ podman ps -a
CONTAINER ID  IMAGE                                COMMAND     CREATED        STATUS                             PORTS                                                             NAMES
776d9477fd0e  localhost/rootnode-ipv4_test:latest              7 minutes ago  Exited (1) Less than a second ago  192.168.178.29:12000->12000/tcp, 192.168.178.29:12000->12000/udp  test_rootnode-ipv4

Dockerfile

# Build SafeNetwork docker container
FROM docker.io/library/alpine:3.14
LABEL version="1.1"
LABEL maintainer="Folât Pjêrsômêj"
LABEL release-date="2021-11-18"

# Update and install dependencies
RUN apk update && apk add \
  bash \
  curl \
  jq

RUN addgroup -g 1000 admin
RUN adduser -s /bin/bash --ingroup admin --uid 1000 --disabled-password admin
USER admin
WORKDIR /home/admin

# Install latest safe network version.
RUN curl -s https://raw.githubusercontent.com/safenetwork-community/safenetwork-dockerfiles/main/scripts/sn_install.sh -o /tmp/sn_install.sh
RUN bash /tmp/sn_install.sh

# Set ENV PATH (after build will be used to find the safe node command)
ENV PATH=$PATH:/home/admin/.safe:/home/admin/.safe/node

# Default env values
ENV ROOTNODE_IP=127.0.0.1
ENV ROOTNODE_PORT=12000

# Expose PORT of the node
EXPOSE $ROOTNODE_PORT

# Assign volume
VOLUME /home/admin/.safe/cli

# Launch safe root node
ENTRYPOINT sn_node -vv --idle-timeout-msec 5500 --keep-alive-interval-msec 4000 --skip-igd --local-addr $ROOTNODE_IP:$ROOTNODE_PORT --public-addr $ROOTNODE_IP:$ROOTNODE_PORT --first

Your error is in the last line of your Dockerfile:

The literal command executed will be --public-addr $ROOTNODE_IP:$ROOTNODE_PORT, where these variables are not interpolated. See this SO answer for an alternative. (There are a handful of instructions that do work with variables, like EXPOSE you are using, see Dockerfile reference | Docker Docs .)

My advice would be to create a script that runs the node. In a Dockerfile I made for running multiple nodes in a single container, I am using this:

Where entrypoint.sh is a script that sets up the nodes.

3 Likes

What the reason you created a container for a local network and not run it directly on the host?

The command is in shell form, so it can’t be that.
I added --clear-data and changed the local address to 0.0.0.0 and now it works.
I’m going to check which one of the two is causing the issue.

One of the reasons is convenience. With Docker it is easy to launch a self-contained network that isn’t influenced by previous iterations. It could also be used to play a part in CI and testing.

Good point, I missed that! I’m very curious now to as to what causes your problem. Have you checked outside of Docker if you can reproduce with sn_node?

2 Likes

With the latest sn_node (0.46.4), I get the following (after replacing --skip-igd with --skip-auto-port-forwarding):

# sn_node -vv --idle-timeout-msec 5500 --keep-alive-interval-msec 4000 --skip-auto-port-forwarding --local-addr 127.0.0.1:12000 --public-addr 127.0.0.1:12000 --first
error: Invalid value for '--public-addr <public-addr>': Cannot use loopback IP for public address. You can drop this option for a local-only network.

The error format differs from your original post, but I guess the error makes sense and 127.0.0.1 should not be used as a public IP.

It’s local address being the lan ip 192.168.x.x that’s not working I just found.
Does the newest sn_node version work?

This topic was automatically closed after 60 days. New replies are no longer allowed.