Skip to content

Bitcoin containerized with complete 442 tests executed during docker build.

Notifications You must be signed in to change notification settings

My-Infra-Repos/Bitcoin-Dockerize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitcoin Dockerize

BitCoin Dockerized: -> What is there

This is a Docker image that runs the Bitcoin -0.21.0 bitcoind node in a container. The checksum have been verfied during the docker image build stageitself. The image contains the main binaries from the Bitcoin Core project - bitcoind, bitcoin-cli and bitcoin-tx. It behaves like a binary, so We can pass any arguments to the image and they will be forwarded to the bitcoind binary. We need to open the requisite ports in docker file

BitCoin Dockerized: -> How to Build the image.

Clone the repository & issue following commands, Note we are implementing CI-CD through GitHub Actions in upcoming publications. say:

docker build -t bitcoinimg:latest .

Security Tests

We do have 442 Security Tests while building Docker Image in dockerfile whereas we also do some Security test on docker images once we complete the dockerbuild. We have put Image test results in test_results file. We also verify the checksum from main bitcoin website before building the fresh image from there.

For testing

        1. Check dockerfile log, I have attached screenshot in document for 442 tests from main Bitcoin Org.
        2. Post Image build we can do image tests by running test/run.sh bitcoinimg:latest

Requirements

        * Physical machine, cloud instance, or VPS that supports Docker , KVM or XEN based VMs) running Ubuntu 14.04 or later (*not OpenVZ containers!*)
        * At least 100 GB to store the block chain files (and always growing!)
        * At least 1 GB RAM + 2 GB swap file

Running in Container:

  1. We need to Create a data volume to persist the bitcoind blockchain data. It will store the data in case of container reboot. Then we will run below commands sh docker volume create --name=data docker run -v data:/bitcoin --name=bitcoin-node -d -p 8333:8333 -p 127.0.0.1:8332:8332 bitcoinimg:latest sh

  2. We can identify the running container

     $ docker ps
     CONTAINER ID        IMAGE                         COMMAND             CREATED             STATUS              PORTS                                              NAMES
     d0e1076b2dca        bitcoin:latest      "btc_oneshot"       2 seconds ago       Up 1 seconds        127.0.0.1:8332->8332/tcp, 0.0.0.0:8333->8333/tcp   bitcoin-node
    
  3. We can then access the daemon's output with below

     docker logs -f bitcoin-node
    

How to interact with the daemon

There are two communications methods to interact with a running Bitcoin Core daemon.

The first one which we have tested is using a cookie-based local authentication. It doesn't require any special authentication information as running a process locally under the same user that was used to launch the Bitcoin Core daemon allows it to read the cookie file previously generated by the daemon for clients. The downside of this method is that it requires local machine access.

The second option is making a remote procedure call using a username and password combination. This has the advantage of not requiring local machine access, but in order to keep Wer credentials safe We should use the newer rpcauth authentication mechanism.

We tested it using cookie-based local authentication

Start by launch the Bitcoin Core daemon:

❯ docker run --rm --name bitcoin-server -it ruimarinho/bitcoin-core \
  -printtoconsole \
  -regtest=1

Then, inside the running bitcoin-server container, locally execute the query to the daemon using bitcoin-cli:

❯ docker exec --user bitcoin bitcoin-server bitcoin-cli -regtest getmininginfo

OutPut will be as mentioned below
=========================================
{
  "blocks": 0,
  "currentblocksize": 0,
  "currentblockweight": 0,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "errors": "",
  "networkhashps": 0,
  "pooledtx": 0,
  "chain": "regtest"
}

-----

About

Bitcoin containerized with complete 442 tests executed during docker build.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published