<p>@PieterWuille is right, it is really not related to bitcoin but to ZeroMQ and docker. I look into the source code and bitcoin core uses <code>zmq_bind( socket, bindingAddress )</code>. For <code>BindingAddress</code>, I can change it to <code>tcp://*:28332</code> because callers from another containers or from host would have different IPs, so the most convenient way is to set it to a range of address or simply <code>tcp://*:28332</code></p>

<p>please refer to ZeroMQ man page at the bottom for more examples <a href="http://api.zeromq.org/4-1:zmq-tcp" rel="nofollow noreferrer">http://api.zeromq.org/4-1:zmq-tcp</a></p>

<p>ANSWER: Release binaries have ZeroMQ statically built-in.</p>

CC BY-SA 4.0
2021-06-20T21:17:58.933Z
Thanks! To get bitcoind and lnd to operate in seperate docker containers, I had to use `network_mode: "host"`, since as you mentioned. zeromq port binding within bitoind is flawed.
pangyuteng
CC BY-SA 4.0
2019-11-21T03:04:30.500Z
2019-11-21T03:19:42.513Z
2019-11-21T03:19:42.513Z
Hami
<p>You may want to try install libzmq in your system and enable zmq in bitcoin.conf.</p>

CC BY-SA 4.0
2019-11-20T13:09:56.457Z
I did. I used https://github.com/ruimarinho/docker-bitcoin-core and I entered the container and installed ZeroMQ manually and enable the bitcoin.conf 
`zmqpubhashblock=tcp://127.0.0.1:28332
zmqpubhashtx=tcp://127.0.0.1:28333`

no luck
Hami
CC BY-SA 4.0
2019-11-20T13:54:26.203Z
I even wrote a mini node.js program to capture the response at the host.
Hami
CC BY-SA 4.0
2019-11-20T14:34:57.903Z
`# ldd /opt/bitcoin-0.17.1/bin/bitcoind
 linux-vdso.so.1 (0x00007ffe29b6c000)
 libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6dd6f8c000)
 librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6dd6f82000)
 libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6dd6dff000)
 libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6dd6de5000)
 libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6dd6c24000)
 /lib64/ld-linux-x86-64.so.2 (0x00007f6dd7c53000)`

it seems that it is not linked even after I installed zmq. how do I link them?
Hami
CC BY-SA 4.0
2019-11-20T21:30:58.770Z
I downvoted. This is unrelated. You need to install libzmq if you're going to compile Bitcoin Core yourself. Release binaries have it statically built-in. It's clear from OP's question that this is the case for him, as ports are opened.
Pieter Wuille
CC BY-SA 4.0
2019-11-21T03:17:45.973Z
@PieterWuille thanks, you point me to the right direction.
Hami
CC BY-SA 4.0
2019-11-20T12:47:58.777Z
2019-11-20T12:47:58.777Z
user11567
<p>I installed the binary and try to listen to ZeroMQ stream. But I got nothing out. Then I installed ZeroMQ but still got nothing.</p>

<p><a href="https://bitcoin.org/en/release/v0.17.1" rel="nofollow noreferrer">https://bitcoin.org/en/release/v0.17.1</a></p>

<p>so, are official bitcoin core releases compiled with zmq in general?</p>

<p>bitcoin.conf</p>

<pre><code>listen=1
upnp=0
txindex=1
maxconnections=40
server=1
rpcthreads=4
rpcuser=alice
rpcpassword=alice
rpcauth=xxxxx
rpcallowip=0.0.0.0/0
rpctimeout=30
txconfirmtarget=6
mempoolexpiry=72
maxmempool=300
maxorphantx=100
debug=rpc
logips=1
limitfreerelay=10
minrelaytxfee=0.0001
zmqpubhashblock=tcp://127.0.0.1:28332
zmqpubhashtx=tcp://127.0.0.1:28333
[main]
rpcbind=192.168.1.107
[test]
rpcbind=0.0.0.0
[regtest]
rpcbind=0.0.0.0
</code></pre>

<p>I found this article <a href="https://bitcoin.stackexchange.com/a/65066/33448">https://bitcoin.stackexchange.com/a/65066/33448</a>
but there is no such file <code>config.log</code>. but I did install successfully with <code>apt-get  --yes install libzmq3-dev</code></p>

<p>docker-compose.yml</p>

<pre><code>....
    bitcoincore:
      image: bitcoincore
      networks:
        - my-network
      build:
        context: bitcoinCore/
      volumes:
        - shared:/rpc
      ports:
        - 8332:8332
        - 8333:8333
        - 18332:18332
        - 18333:18333
        - 18443:18443
        - 18444:18444
        - 28332:28332
        - 28333:28333
....
</code></pre>

<p>net stat -pant</p>

<pre><code>Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:18332           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:18333           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.11:35491        0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:28332 &lt;---    0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:28333 &lt;---    0.0.0.0:*               LISTEN      -                   
tcp        0      0 172.22.0.2:38722        31.220.15.89:18333      ESTABLISHED -                   
tcp        0      0 172.22.0.2:60910        193.31.24.45:18333      TIME_WAIT   -                   
tcp        0      0 172.22.0.2:40730        159.203.125.125:18333   ESTABLISHED -                   
tcp        0      0 172.22.0.2:60938        54.162.188.154:18333    ESTABLISHED -                   
tcp        0      0 127.0.0.1:58746         127.0.0.1:18332         TIME_WAIT   -                   
tcp6       0      0 :::18333                :::*                    LISTEN      -             
</code></pre>

<p>getzmqnotifications(inside container)</p>

<pre><code>#  bitcoin-cli -testnet -rpcuser=alice -rpcpassword=alice getzmqnotifications
[
  {
    "type": "pubhashblock",
    "address": "tcp://127.0.0.1:28332"
  },
  {
    "type": "pubhashtx",
    "address": "tcp://127.0.0.1:28333"
  }
]
</code></pre>

<p>test RPC at host</p>

<pre><code>$ curl --user alice:alice -H 'content-type:text/plain;' http://localhost:18332/ --data-binary '{"jsonrpc":"1.0","id":"1","method":"getmininginfo"}'
{"result":{"blocks":1348883,"currentblockweight":0,"currentblocktx":0,"difficulty":4194304,"networkhashps":48545593617877.57,"pooledtx":0,"chain":"test","warnings":""},"error":null,"id":"1"}
</code></pre>

<p>try to use lld to find out if dependency is ok, but no luck</p>

<pre><code># ldd /opt/bitcoin-0.17.1/bin/bitcoind
    linux-vdso.so.1 (0x00007ffe29b6c000)
    libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6dd6f8c000)
    librt.so.1 =&gt; /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6dd6f82000)
    libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6dd6dff000)
    libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6dd6de5000)
    libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6dd6c24000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f6dd7c53000)

</code></pre>

<p>tester.js</p>

<pre><code>var zmq = require('zeromq')
  , sock = zmq.socket('sub')
  , RpcClient = require('bitcoind-rpc')
  , bitcoin = require("bitcoinjs-lib");

var config = {
    protocol: 'http',
    user: 'alice',
    pass: 'alice',
    host: 'localhost',
    port: '18332',
};

var rpc = new RpcClient(config);

sock.connect('tcp://localhost:28333');

sock.on('message', function(topic, message) {
console.log(topic, message);
  var tx = bitcoin.Transaction.fromHex(message)
  if (!tx.isCoinbase()) {
    rpc.generate(1, console.log)
   console.log(topic, message)
  }
})

// Subscribe to receive messages for a specific topic.
// This can be "hashblock", "hashtx", "rawtx", or "rawblock".
//sock.subscribe('rawtx');
sock.subscribe('hashtx');

rpc.getDifficulty( (err, data) =&gt; {
    if (err) {
        console.log(err);
        return;
    }
    console.log('RPC working Ok; obtain difficulty as followed: ',data);
    console.log('listening....');
});

</code></pre>

CC BY-SA 4.0
2019-11-20T20:22:06.737Z
Release binaries are statically linked, so the fact that you don't see a dependency on libzmq is not a surprise. It's also unnecessary to install anything as it's all built into the `bitcoind` binary. If it wasn't included you wouldn't be seeing the TCP listen on those ports. The fact that things don't work is probably due to an unrelated issue.
Pieter Wuille
<bitcoin-core><bitcoind><zeromq>
are official bitcoin core released compiled with zmq in general?
Hami
# are official bitcoin core released compiled with zmq in general?

(Asked by: username_0 on 2019-11-20)

I installed the binary and try to listen to ZeroMQ stream. But I got nothing out. Then I installed ZeroMQ but still got nothing.

<https://bitcoin.org/en/release/v0.17.1>

so, are official bitcoin core releases compiled with zmq in general?

bitcoin.conf

```
listen=1
upnp=0
txindex=1
maxconnections=40
server=1
rpcthreads=4
rpcuser=alice
rpcpassword=alice
rpcauth=xxxxx
rpcallowip=0.0.0.0/0
rpctimeout=30
txconfirmtarget=6
mempoolexpiry=72
maxmempool=300
maxorphantx=100
debug=rpc
logips=1
limitfreerelay=10
minrelaytxfee=0.0001
zmqpubhashblock=tcp://127.0.0.1:28332
zmqpubhashtx=tcp://127.0.0.1:28333
[main]
rpcbind=192.168.1.107
[test]
rpcbind=0.0.0.0
[regtest]
rpcbind=0.0.0.0

```

I found this article <https://bitcoin.stackexchange.com/a/65066/33448>
but there is no such file `config.log`. but I did install successfully with `apt-get --yes install libzmq3-dev`

docker-compose.yml

```
....
    bitcoincore:
      image: bitcoincore
      networks:
        - my-network
      build:
        context: bitcoinCore/
      volumes:
        - shared:/rpc
      ports:
        - 8332:8332
        - 8333:8333
        - 18332:18332
        - 18333:18333
        - 18443:18443
        - 18444:18444
        - 28332:28332
        - 28333:28333
....

```

net stat -pant

```
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:18332           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:18333           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.11:35491        0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:28332 <---    0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:28333 <---    0.0.0.0:*               LISTEN      -                   
tcp        0      0 172.22.0.2:38722        31.220.15.89:18333      ESTABLISHED -                   
tcp        0      0 172.22.0.2:60910        193.31.24.45:18333      TIME_WAIT   -                   
tcp        0      0 172.22.0.2:40730        159.203.125.125:18333   ESTABLISHED -                   
tcp        0      0 172.22.0.2:60938        54.162.188.154:18333    ESTABLISHED -                   
tcp        0      0 127.0.0.1:58746         127.0.0.1:18332         TIME_WAIT   -                   
tcp6       0      0 :::18333                :::*                    LISTEN      -             

```

getzmqnotifications(inside container)

```
#  bitcoin-cli -testnet -rpcuser=alice -rpcpassword=alice getzmqnotifications
[
  {
    "type": "pubhashblock",
    "address": "tcp://127.0.0.1:28332"
  },
  {
    "type": "pubhashtx",
    "address": "tcp://127.0.0.1:28333"
  }
]

```

test RPC at host

```
$ curl --user alice:alice -H 'content-type:text/plain;' http://localhost:18332/ --data-binary '{"jsonrpc":"1.0","id":"1","method":"getmininginfo"}'
{"result":{"blocks":1348883,"currentblockweight":0,"currentblocktx":0,"difficulty":4194304,"networkhashps":48545593617877.57,"pooledtx":0,"chain":"test","warnings":""},"error":null,"id":"1"}

```

try to use lld to find out if dependency is ok, but no luck

```
# ldd /opt/bitcoin-0.17.1/bin/bitcoind
    linux-vdso.so.1 (0x00007ffe29b6c000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6dd6f8c000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6dd6f82000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6dd6dff000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6dd6de5000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6dd6c24000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f6dd7c53000)

```

tester.js

```
var zmq = require('zeromq')
  , sock = zmq.socket('sub')
  , RpcClient = require('bitcoind-rpc')
  , bitcoin = require("bitcoinjs-lib");

var config = {
    protocol: 'http',
    user: 'alice',
    pass: 'alice',
    host: 'localhost',
    port: '18332',
};

var rpc = new RpcClient(config);

sock.connect('tcp://localhost:28333');

sock.on('message', function(topic, message) {
console.log(topic, message);
  var tx = bitcoin.Transaction.fromHex(message)
  if (!tx.isCoinbase()) {
    rpc.generate(1, console.log)
   console.log(topic, message)
  }
})

// Subscribe to receive messages for a specific topic.
// This can be "hashblock", "hashtx", "rawtx", or "rawblock".
//sock.subscribe('rawtx');
sock.subscribe('hashtx');

rpc.getDifficulty( (err, data) => {
    if (err) {
        console.log(err);
        return;
    }
    console.log('RPC working Ok; obtain difficulty as followed: ',data);
    console.log('listening....');
});

```

**Tags:** bitcoin-core, bitcoind, zeromq

> **Comments:**
> **username_1**: Release binaries are statically linked, so the fact that you don't see a dependency on libzmq is not a surprise. It's also unnecessary to install anything as it's all built into the `bitcoind` binary. If it wasn't included you wouldn't be seeing the TCP listen on those ports. The fact that things don't work is probably due to an unrelated issue.  

---

## 2 answers

### Answer by username_0 on 2019-11-21. Score: 4

@username_1 is right, it is really not related to bitcoin but to ZeroMQ and docker. I look into the source code and bitcoin core uses `zmq_bind( socket, bindingAddress )`. For `BindingAddress`, I can change it to `tcp://*:28332` because callers from another containers or from host would have different IPs, so the most convenient way is to set it to a range of address or simply `tcp://*:28332`

please refer to ZeroMQ man page at the bottom for more examples <http://api.zeromq.org/4-1:zmq-tcp>

ANSWER: Release binaries have ZeroMQ statically built-in.

> **Comments:**
> **username_2**: Thanks! To get bitcoind and lnd to operate in seperate docker containers, I had to use `network_mode: "host"`, since as you mentioned. zeromq port binding within bitoind is flawed.  

---

### Answer by username_3 on 2019-11-20. Score: -1

You may want to try install libzmq in your system and enable zmq in bitcoin.conf.

> **Comments:**
> **username_0**: I did. I used https://github.com/ruimarinho/docker-bitcoin-core and I entered the container and installed ZeroMQ manually and enable the bitcoin.conf  `zmqpubhashblock=tcp://127.0.0.1:28332 zmqpubhashtx=tcp://127.0.0.1:28333`  no luck  
> **username_0**: I even wrote a mini node.js program to capture the response at the host.  
> **username_0**: `# ldd /opt/bitcoin-0.17.1/bin/bitcoind  linux-vdso.so.1 (0x00007ffe29b6c000)  libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6dd6f8c000)  librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6dd6f82000)  libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6dd6dff000)  libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6dd6de5000)  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6dd6c24000)  /lib64/ld-linux-x86-64.so.2 (0x00007f6dd7c53000)`  it seems that it is not linked even after I installed zmq. how do I link them?  
> **username_1**: I downvoted. This is unrelated. You need to install libzmq if you're going to compile Bitcoin Core yourself. Release binaries have it statically built-in. It's clear from OP's question that this is the case for him, as ports are opened.  
> **username_0**: @username_1 thanks, you point me to the right direction.  

---

