Bitcoin testnet syncing node docker compose setup

Calender

12th April 2021

Clock

102 min read

Author
Chirag Kumar

Lead Devops

A bitcoin syncing node is a program that fully validates transactions and downloads blocks on the blockchain. Almost Every full node also help the network of nodes by accepting the transactions and blocks of blockchain from other full syncing nodes. These nodes helps in validating those transactions and blocks, and then relaying them to the further full syncing nodes of bitcoin.

Most of the full syncing nodes also give lightweight clients so that they can send their transactions on to the network and notify them when a transaction are executed successfully. If not a specific number of nodes perform this function, clients won't be able to connect through the peer-to-peer network"”they'll have to use centralized services instead.

Many people and organizations Prefer to run full nodes using their spare computing and bandwidth resources, also, more volunteers are needed to allow Bitcoin to continue to grow. 

 

Minimum Requirements for linux setup

Bitcoin Core full syncing nodes have some certain requirements which are necessary. If you try running a bitcoin node on weak hardware, it may work"”but you'll likely spend more time dealing with issues. The suggested minimum requirement for the node is given below.

 

  • Any machine (can be Cloud, Desktop or laptop hardware) running recent versions of Linux(can be ubuntu, centos, Redhat etc).
     
  • 350 gigabytes of free disk space, accessible at a minimum read/write speed of 100 MB/s(Preferred SSD).
     
  • 4 gigabytes of memory (RAM)
     
  • An Internet connection with upload speeds of at least 400 kilobits (50 kilobytes) per second
     
  • A connection with high upload limits, or a connection you regularly monitor to ensure it doesn't exceed its upload limits.
     
  • Your full node can be left running. (You can do other things with your computer while running a full node.) It is preferred if you can run your node continuously.

     



 

Steps for running blockchain node on docker compose


 

1.Create the following File structure:

 

|-- bitcoind_src/

|   `-- Dockerfile

|   `-- bitcoin.conf

|-- docker-compose.yml



 

2.Copy the Dockerfile in the mentioned path

 

FROM ubuntu:16.04

RUN apt-get update -y && \
apt-get install software-properties-common -y && \
apt-get install wget

ENV BITCOIN_VER="0.17.0.1"
ENV BITCOIN_FOLDER_VER="0.17.0"
ENV BITCOIN_SHASUM="6ccc675ee91522eee5785457e922d8a155e4eb7d5524bd130eb0ef0f0c4a6008"
WORKDIR /tmp

RUN wget -O bitcoin-${BITCOIN_VER}-x86_64-linux-gnu.tar.gz https://bitcoin.org/bin/bitcoin-core-${BITCOIN_VER}/bitcoin-${BITCOIN_VER}-x86_64-linux-gnu.tar.gz

RUN CURRENTHASH=$(sha256sum "bitcoin-${BITCOIN_VER}-x86_64-linux-gnu.tar.gz" | cut -d' ' -f1); \
if [ "${CURRENTHASH}" = "${BITCOIN_SHASUM}" ] ; \
then echo "checksum ok"; \
else echo "checksum failed for bitcoin-${BITCOIN_VER}-x86_64-linux-gnu.tar.gz"; exit 255 ; \
fi
RUN tar -xvzf bitcoin-${BITCOIN_VER}-x86_64-linux-gnu.tar.gz
RUN install -C -m 755 -o root -g root --backup=off bitcoin-${BITCOIN_FOLDER_VER}/bin/* /usr/bin/
RUN rm bitcoin-${BITCOIN_VER}-x86_64-linux-gnu.tar.gz && rm -rf bitcoin-${BITCOIN_FOLDER_VER}
RUN apt update
RUN apt install curl -y

RUN mkdir -p /root/.bitcoin/

WORKDIR /root/.bitcoin/
COPY ./bitcoin.conf /root/.bitcoin/
COPY ./wallet.sh /root/.bitcoin/
RUN chmod +x /root/.bitcoin/wallet.sh
EXPOSE 8332 8333 18332 18333

CMD ["/usr/bin/bitcoind", "-deprecatedrpc=accounts"]

 

3.Copy the bitcoin.conf on the mentioned path

 

server=1
testnet=1
rpcuser=RPC_user
rpcpassword=RPC_password

rpcallowip=0.0.0.0/0
rpcport=8332





 

4.Copy the docker-compose.yml on the mentioned path

 

version: '3'
services:

  bitcoin:
    build: build_src
    container_name: bitcoin
    restart: always
    networks:
      - "bitcoin"
    volumes:
      - ./data/bitcoin:/root/.bitcoin
      - ./build_src/bitcoin.conf:/root/.bitcoin/bitcoin.conf
    ports:
      - "8333:8333"
      - "8332:8332"
      - "18333:18333"
      - "18332:18332"

networks:
  bitcoin:
    driver: bridge

 


 

6.Run the following commands to interact with bitcoin node on docker compose.


 

To Start bitcoin Node

docker-compose start  bitcoin

To Stop bitcoin Node

docker-compose stop  bitcoin

To check bitcoin Node Status

docker-compose exec bitcoin bitcoin-cli getblockchaininfo

 

Author Chirag Kumar

Chirag is an highly accomplished DevOps engineer with a wealth of experience in NGINX, Apache, AWS, Compose, Docker, ECS, Kubernetes, shell scripting, Linux, Jenkins, SonarQube, Terraform, and other cutting-edge technologies. His expertise lies in automating and optimizing development and deployment processes through the utilization of various tools and techniques. Chirag's strong background in troubleshooting and problem-solving has been instrumental in ensuring the reliability and availability of systems and services. Throughout his career, he has contributed to numerous projects, including Wethio, Wethio Exchange, Hedgex, Bluechain, Coinzoom, and more.

Lead Devops

bg bg

What's Trending in Tech

bg

Our Offices

India

INDIA

DG-18-009, Tower B,
Emaar Digital Greens, Sector 61,
Gurugram, Haryana
122011.
Unit- 117-120, First Floor,
Welldone Tech Park,
Sector 48, Sohna road,
Gurugram, Haryana
122018.
USA

USA

30N, Gloud St STR E, Sheridan, Wyoming (USA) - 82801
Singapore

SINGAPORE

10 Anson Road, #13-09, International Plaza Singapore 079903.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.