Docker Container is not using docker0 network in linux and how to connect the Containers to docker0 network?

I am facing something weird when I am running my docker container,

To give a bit of a background, I am using one of balena images to build my docker container using a Beaglebone image.

I have used the following documentation Balena Base Images Documentation and tried to find an image that would be as close as possible to one of the beaglebones that I have. I used the following documentation Balena DeviceType list where I found that the closest type is
(BeagleBone Black-beaglebone-black; Type: armv7hf) and got to the beaglebone image using the following link from GitHub Targeted Beaglebone Image

I created the following DockerFile:

FROM balenalib/armv7hf-debian:buster-build
LABEL io.balena.device-type="beaglebone-black"
RUN echo "deb [arch=armhf] http://repos.rcn-ee.net/debian/ buster main" >> /etc/apt/sources.list \
	&& apt-key adv --batch --keyserver keyserver.ubuntu.com --recv-key D284E608A4C46402

RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential \
        bash \
		less \
        file \
		kmod \
		nano \
		net-tools \
		ifupdown \
		iputils-ping \
		i2c-tools \
		usbutils \
        libgpiod-dev \
        # to copy files between rootfs directories
        rsync \
        # to generate partition table and alter partitions
        parted \
        gdisk \
        # to be able to detect file system types of extracted images
        file \
        # zip and unzip archive
        zip  \
        unzip \
        # manipulate binary and hex
        xxd \
        # JSON power tool
        jq \
        # GRUB command line tools, primarily grub-probe
        grub-common \
        # to be able to run package installations on foreign architectures
        qemu-user-static \
        # Parallel gzip compression
        pigz \
        sudo \
        # to enable use of crontab
        cron \
        # to ignore #<escape>r command error
        dos2unix \
        # Base Image packages
        gpiod \
        libgpiod2 \
        libgpiod-dev \
        ssh \
        openssh-server \
        ufw \
        setserial \
        iproute2 \
        net-tools \
        iputils-ping \
        inetutils-traceroute \
        curl telnet dnsutils vim \
        lsof \
        systemd \
        tcpdump \
        socat \
        ppp \
        connman \
        dbus \
	&& rm -rf /var/lib/apt/lists/*

Rest of the code is just installing c++ packages for using a service to send and receive messages. After building the container and running it (which will also run the c++ service), it does not seem to be able to utilise the default docker bridge if I don’t specify a network. If I used ifconfig I got the following outcome:

ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:22ff:fe5c:ccd5  prefixlen 64  scopeid 0x20<link>
        ether 02:42:22:5c:cc:d5  txqueuelen 0  (Ethernet)
        RX packets 11  bytes 532 (532.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 811 (811.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ip route show
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 

ip link show
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default 
    link/ether 02:42:22:5c:cc:d5 brd ff:ff:ff:ff:ff:ff

networkctl | grep docker0
  3 docker0     bridge   no-carrier  unmanaged

and if I try to send and receive messages using simple c++ code from another PC on the same network, I can see in the docker desktop that the container receives the message from the files tab (by writing to log message that it received the message), however, the container is not sending response back to the second PC.

On the other hand, if I use like busybox image and do the following command

docker run -it busybox
/ # ping google.com
PING google.com (142.250.178.14): 56 data bytes
64 bytes from 142.250.178.14: seq=0 ttl=111 time=19.409 ms
64 bytes from 142.250.178.14: seq=1 ttl=111 time=19.998 ms
64 bytes from 142.250.178.14: seq=2 ttl=111 time=19.528 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 19.409/19.645/19.998 ms
(In different command window)

networkctl | grep docker0
  3 docker0     bridge   routable    unmanaged

But, the busybox commands above worked when I re-installed docker, then it reverted back to the same issue above in the part of the commands with ifconfig where it can’t ping google.com. So couple of questions:

  1. How can I get the docker containers (if I am going to use the bridge) to connect to docker0 and use that network permanently? (Because I have been installing and uninstalling docker in Ubuntu 24.04 a lot where I get the response from busybox when pinging for the first time [after fresh install] and then the network bridge is down permanently)
  2. How can I make my Balena docker container communicate with the second PC as the container is not able to send messages back (say acknowledgement messages) to the second PC?
  3. Could be that I am using build when I should be using run in the DockerFile?

Edit 1:

I used all the steps that were mentioned in docker0 interface keeps losing IPv4 ipaddress Especially Docker setup with dokcer0 but it didn’t work

Edit 2:

Could it be the issue that docker desktop is using 192.168.65.0/24? if it is, how to change it to work with 172.17.0.1 to work with docker0?