user33448: 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....');
});



user33448: @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 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.

33448: <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>
 33448: <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>
