Unable to publish ports when running Docker image on Buildroot Linux

Hello. Having an issue with Docker that’s been stumping me.

My target is an Intel NUC with 32gb of RAM and a Tigerlake processor. It does not have access to the internet, but is on my local network so I can SSH to the target.

The target is running Buildroot Linux and has Docker version 20.10.14 built into it. It is using a 14GB ramdisk. To faciliate the ramdisk, I run the Docker daemon as such:
DOCKER_RAMDISK=true dockerd &

Which allows me to run Docker containers without issue (without that env var set, it wasn’t working)

I’m pulling images down on my host PC which does have internet access, using “docker save” and exporting to a tarball, and then transferring them to the Buildroot Linux target on the NUC via SCP. I then use docker load to import the image onto Docker on the NUC, and can then run them. All that works.

My issue comes when I try to publish a port.

Example: docker run -p 8042:3000 <image>

On the client side, I get this error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint magical_dubinsky (f37f231f990f6cf8d018af071dd87c816fcb78a331b0c45975846c9a18a19a4b): Error starting userland proxy: listen tcp [::]:8042: bind: address already in us

On my shell running dockerd, I get this:

INFO[1970-01-01T00:10:28.953156701Z] /etc/resolv.conf does not exist              
INFO[1970-01-01T00:10:28.953272185Z] No non-localhost DNS nameservers are left in resolv.conf. Using default external servers: [nameserver 8.8.8.8 nameserver 8.8.4.4] 
INFO[1970-01-01T00:10:28.953296383Z] IPv6 enabled; Adding default IPv6 external servers: [nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844] 
WARN[1970-01-01T00:10:28.962286489Z] Failed to allocate and map port 8042-8042: Error starting userland proxy: listen tcp [::]:8042: bind: address already in use 
ERRO[1970-01-01T00:10:28.971345455Z] 8e94314ee2421356e37a1730b36cce89fafba42f6080a516ca0d93381d870894 cleanup: failed to delete container from containerd: no such container 
ERRO[1970-01-01T00:10:28.971413409Z] Handler for POST /v1.41/containers/8e94314ee2421356e37a1730b36cce89fafba42f6080a516ca0d93381d870894/start returned error: driver failed programming external connectivity on endpoint magical_dubinsky (f37f231f990f6cf8d018af071dd87c816fcb78a331b0c45975846c9a18a19a4b): Error starting userland proxy: listen tcp [::]:8042: bind: address already in use

At first, I thought it was an obvious error… something must be using port 8042, so I just need to use a different port or stop the process using 8042.

However, using lsof, netstat and ss, I can find nothing using port 8042. So then I tried other ports - 4000, 10000, 20000, 50000… all get the same error, and none are in use.

This is what I see when I run ip addr:
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
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 6e:8c:69:52:9a:39 brd ff:ff:ff:ff:ff:ff
3: enp88s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 48:21:0b:36:2b:a8 brd ff:ff:ff:ff:ff:ff
    inet 10.20.31.66/24 scope global enp88s0
       valid_lft forever preferred_lft forever
    inet6 fe80::4a21:bff:fe36:2ba8/64 scope link 
       valid_lft forever preferred_lft forever
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:6a:8f:7a:8b brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:6aff:fe8f:7a8b/64 scope link 
       valid_lft forever preferred_lft forever

Any ideas why I can’t publish any ports?

Thank you!

I was able to resolve this issue. Apparently there are issues with ipv6 on this Buildroot target, and Docker tries to bind to ipv4 and ipv6 by default.

I changed the command to

-p “0.0.0.0:8042:3000”

Which forced it to use ipv4 only and it worked.