The only way to connect to peers is through a DGRAM unix socket?

I’m running an experimental setup. I have Ubuntu on my desktop computer with a USB hub connected and a 1TB ssd sata drive mounted to it at /mnt/d1

I’m using a second docker instance

dockerd -H unix:///var/run/docker1.sock -p /var/run/docker1.pid --ip-masq=true --bridge=docker1 --data-root=/mnt/d1/docker-data --exec-root=/mnt/d1/docker-exec
dockerd -H unix:///var/run/docker1.sock run -itd --network=host --privileged --hostname test --user root --name test 20:latest
dockerd -H unix:///var/run/docker1.sock exec --user root -it 18 /bin/bash
# installed bitcoind here

Next I set up my custom datadir in /home/BTC where I write in my bitcoin.conf the normal bitcoin port and rpc port

rpcuser=redacted
rpcpassword=redacted
port=8333
rpcport=8332
listen=1
datadir=/home/BTC

When I start Bitcoind like bitcoind -datadir=/home/BTC it is unable to get any connections and I see in debug.log

Bound to [::]:11235
Bound to 0.0.0.0:11235

Long-story-short; I tried putting the port out of range 999999999999999
then ran bitcoind again

Bound to [::]:25177
Bound to 0.0.0.0:25177

So now it has connections and gets blocks but I am confused as to what happened.

netstat -anp | grep "25177"
  unix 3 [ ] DGRAM CONNECTED 25177 1/init
netstat -anp | grep "DGRAM" | grep "1/init"
unix  4      [ ]         DGRAM      CONNECTED     16138    1/init               /run/systemd/notify
unix  2      [ ]         DGRAM                    22988    1/init               /run/systemd/journal/syslog
unix  24     [ ]         DGRAM      CONNECTED     22997    1/init               /run/systemd/journal/dev-log
unix  8      [ ]         DGRAM      CONNECTED     22999    1/init               /run/systemd/journal/socket
unix  3      [ ]         DGRAM      CONNECTED     33808    1/init               
unix  3      [ ]         DGRAM      CONNECTED     25176    1/init               
unix  3      [ ]         DGRAM      CONNECTED     16139    1/init               
unix  3      [ ]         DGRAM      CONNECTED     16140    1/init               
unix  3      [ ]         DGRAM      CONNECTED     25177    1/init               
unix  3      [ ]         DGRAM      CONNECTED     33807    1/init               
unix  2      [ ]         DGRAM      CONNECTED     25779    1/init

Somehow it connected through! how would I reproduce one of these DGRAM unix sockets to let it through on port 8333?

This is an interesting take. I didn’t know the daemon binary can actually be used to run (as in create+start) or exec into containers. Didn’t it create a docker demon instance every time?

I would have done the last two commands differently:

export DOCKER_HOST=unix:///var/run/docker1.sock
docker run -d --network=host --privileged --hostname test --user root --name test 20:latest
docker exec --user root -it test /bin/bash

As an alternative approach, you could create a docker context and register unix:///var/run/docker1.sock as context. This would allow switching contexts between the started docker daemons.

This is not what actually happens. When you start a container without network namespace isolation (like you did with --network=host), then the container uses all host network interfaces directly. Your container doesn’t care or require the unix domain socket (unless the application inside the container actually requires a unix domain socket itself). Though, your docker demon instance will expose it’s rest api on it, and the docker cli needs to use it, to control the 2nd docker demon instance.

1 Like

I’ve done my own script where I get to switch between doker and docker1

dk 1 run …
dk 0 exec …

my

dockerd -H unix:///var/run/docker1.sock -p /var/run/docker1.pid --ip-masq=true --bridge=docker1 --data-root=/mnt/d1/docker-data --exec-root=/mnt/d1/docker-exec

–bridge=docker1

maybe wrong, I created it by:

brctl addbr docker1
ip addr add 172.19.0.1/16 dev mn1
ip link set dev docker1 up
dockerd -H unix:///var/run/docker1.sock -p /var/run/docker1.pid --ip-masq=true --bridge=docker1 --data-root=/mnt/d1/docker-data --exec-root=/mnt/d1/docker-exec >/dev/null 2>&1 &

I just don’t understand why I haven’t got normal tcp port access both ways! something is blocking!? This driving me nuts! I just want to use ports in/out recieve/reply normally on what ever port is available but NONE work!

the docker documentation link I tried to send you looks like this:

Run multiple daemons

Note:

Running multiple daemons on a single host is considered as “experimental”. The user should be aware of unsolved problems. This solution may not work properly in some cases. Solutions are currently under development and will be delivered in the near future.

This section describes how to run multiple Docker daemons on a single host. To run multiple daemons, you must configure each daemon so that it does not conflict with other daemons on the same host. You can set these options either by providing them as flags, or by using a daemon configuration file.

The following daemon options must be configured for each daemon:

-b, --bridge=                          Attach containers to a network bridge
--exec-root=/var/run/docker            Root of the Docker execdriver
--data-root=/var/lib/docker            Root of persisted Docker data
-p, --pidfile=/var/run/docker.pid      Path to use for daemon PID file
-H, --host=[]                          Daemon socket(s) to connect to
--iptables=true                        Enable addition of iptables rules
--config-file=/etc/docker/daemon.json  Daemon configuration file
--tlscacert="~/.docker/ca.pem"         Trust certs signed only by this CA
--tlscert="~/.docker/cert.pem"         Path to TLS certificate file
--tlskey="~/.docker/key.pem"           Path to TLS key file

When your daemons use different values for these flags, you can run them on the same host without any problems. It is very important to properly understand the meaning of those options and to use them correctly.

  • The -b, --bridge= flag is set to docker0 as default bridge network. It is created automatically when you install Docker. If you are not using the default, you must create and configure the bridge manually or just set it to ‘none’: --bridge=none
  • --exec-root is the path where the container state is stored. The default value is /var/run/docker. Specify the path for your running daemon here.
  • --data-root is the path where persisted data such as images, volumes, and cluster state are stored. The default value is /var/lib/docker. To avoid any conflict with other daemons, set this parameter separately for each daemon.
  • -p, --pidfile=/var/run/docker.pid is the path where the process ID of the daemon is stored. Specify the path for your pid file here.
  • --host=[] specifies where the Docker daemon will listen for client connections. If unspecified, it defaults to /var/run/docker.sock.
  • --iptables=false prevents the Docker daemon from adding iptables rules. If multiple daemons manage iptables rules, they may overwrite rules set by another daemon. Be aware that disabling this option requires you to manually add iptables rules to expose container ports. If you prevent Docker from adding iptables rules, Docker will also not add IP masquerading rules, even if you set --ip-masq to true. Without IP masquerading rules, Docker containers will not be able to connect to external hosts or the internet when using network other than default bridge.
  • --config-file=/etc/docker/daemon.json is the path where configuration file is stored. You can use it instead of daemon flags. Specify the path for each daemon.
  • --tls* Docker daemon supports --tlsverify mode that enforces encrypted and authenticated remote connections. The --tls* options enable use of specific certificates for individual daemons.

Example script for a separate “bootstrap” instance of the Docker daemon without network:

content_copy

$ sudo dockerd \
        -H unix:///var/run/docker-bootstrap.sock \
        -p /var/run/docker-bootstrap.pid \
        --iptables=false \
        --ip-masq=false \
        --bridge=none \
        --data-root=/var/lib/docker-bootstrap \
        --exec-root=/var/run/docker-bootstrap

I was referring to the commands to create or exec the container, I was surprised to see dockerd (=the demon) being used instead of docker (=the client).

As I never felt the need to run more than a single docker demon on a host, I leave this for someone else to answer.

ah, I see, I first came across this Is it possible to start multiple docker daemons on the same machine - Stack Overflow

I think I f***d the network or something though

the guy who answers is doing it like that and it does work - I can confirm!
I don’t understand what is restricting me from using any ports properly though. Now today I can’t even use that 25177 unix DGRAM port that I was sort of hijacking. It’s litterally just stopped working so now I am stuck with no tcp ports to use :triumph: