Docker-compose部署LTC同步节点

1、下载ltc程序包,litecoin下载地址
下载页

handlebars 复制代码
mkdir /data/docker-compose/ltc
cd /data/docker-compose/ltc
https://github.com/litecoin-project/litecoin/releases/download/v0.21.3/litecoin-0.21.3-x86_64-linux-gnu.tar.gz

2、编写dockerfile和bitcoin.conf

bitcoin.conf

config 复制代码
cat bitcoin.conf
server=1
txindex=1
listen=1
rpcbind=0.0.0.0:9332
rpcallowip=0.0.0.0/0
rpcport=9332
rpcuser=root
rpcpassword=123456
uacomment=litecoin
datadir=/litecoin/data

Dockerfile

Dockerfile 复制代码
FROM ubuntu:20.04

# 安装依赖库和工具
RUN apt-get update && apt-get install -y \
    curl \
    libssl-dev \
    libevent-dev \
    software-properties-common

ADD litecoin-0.21.3-x86_64-linux-gnu.tar.gz .
# 解压并复制二进制文件到 /usr/local/bin 目录
RUN mv litecoin-0.21.3/bin/litecoind /usr/local/bin/ && \
    mv litecoin-0.21.3/bin/litecoin-cli /usr/local/bin/ && \
    rm -rf litecoin-0.21.3 

# 配置 Bitcoin Cash 节点
COPY litecoin.conf /root/.litecoin/litecoin.conf

# 暴露节点端口
EXPOSE 9332 9333

# 启动 Bitcoin Cash 节点
CMD ["/usr/local/bin/litecoind", "--conf=/root/.litecoin/litecoin.conf", "--printtoconsole"]

3、编译镜像

handlebars 复制代码
~# docker build -t devocenter/litecoin .
[+] Building 1.9s (11/11) FINISHED                                                                                                                                                                                             docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 699B                                                                                                                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                                          1.8s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                                                                                                                                                                            0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                          0.0s
 => [1/5] FROM docker.io/library/ubuntu:20.04@sha256:21ae67bf44d1d0a53ecdce48742c766e44aea4d16e18a3b88a3888eddaf782b5                                                                                                                    0.0s
 => [internal] load build context                                                                                                                                                                                                        0.0s
 => => transferring context: 264B                                                                                                                                                                                                        0.0s
 => CACHED [2/5] RUN apt-get update && apt-get install -y     curl     libssl-dev     libevent-dev     software-properties-common                                                                                                        0.0s
 => CACHED [3/5] ADD litecoin-0.21.3-x86_64-linux-gnu.tar.gz .                                                                                                                                                                           0.0s
 => CACHED [4/5] RUN mv litecoin-0.21.3/bin/litecoind /usr/local/bin/ &&     mv litecoin-0.21.3/bin/litecoin-cli /usr/local/bin/ &&     rm -rf litecoin-0.21.3                                                                           0.0s
 => [5/5] COPY litecoin.conf /root/.litecoin/litecoin.conf                                                                                                                                                                               0.0s
 => exporting to image                                                                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                                                                  0.0s
 => => writing image sha256:d2a95e0f8ee1e369e2c30f4d16e9d1ef2d5fd6738dec4e7e35b35ef59f3692fa                                                                                                                                             0.0s
 => => naming to docker.io/devocenter/litecoin

4、镜像打tag push到仓库

handlebars 复制代码
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker tag d2a95e0f8ee1 devocenter/litecoin:v0.21.3
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker images
REPOSITORY            TAG       IMAGE ID       CREATED         SIZE
devocenter/litecoin   latest    d2a95e0f8ee1   2 minutes ago   396MB
devocenter/litecoin   v0.21.3   d2a95e0f8ee1   2 minutes ago   396MB
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker login docker.io
Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.
You can log in with your password or a Personal Access Token (PAT). Using a limited-scope PAT grants better security and is required for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/

Username: devocenter
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker push devocenter/litecoin:v0.21.3
The push refers to repository [docker.io/devocenter/litecoin]
1990ef79999f: Pushed 
090faf555056: Layer already exists 
6c066eebe679: Layer already exists 
9de7d6e778cc: Layer already exists 
e915d510ff2b: Layer already exists 
v0.21.3: digest: sha256:6d80ac2495c2497f2c8ce99a55302c66d1d7da25edd67ea925fc7663a130ac88 size: 1371
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker push devocenter/litecoin
Using default tag: latest
The push refers to repository [docker.io/devocenter/litecoin]
1990ef79999f: Layer already exists 
090faf555056: Layer already exists 
6c066eebe679: Layer already exists 
9de7d6e778cc: Layer already exists 
e915d510ff2b: Layer already exists 
latest: digest: sha256:6d80ac2495c2497f2c8ce99a55302c66d1d7da25edd67ea925fc7663a130ac88 size: 1371

5、编写docker-compose.yaml文件

yaml 复制代码
version: '3'

services:
  lite-node:
    image: devocenter/litecoin
    volumes:
      - ./bitcoin.conf:/root/.bitcoin/bitcoin.conf
      - ./data:/litecoin/data
    restart: always        
    ports:
      - 9332:9332
      - 9333:9333

6、启动容器

handlebars 复制代码
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker-compose up -d
WARN[0000] /data/ltc/docker-compose.yaml: `version` is obsolete 
[+] Running 2/2
 ✔ Network ltc_default       Created                                                                                                                                                                                                     0.0s 
 ✔ Container ltc-bch-node-1  Started                                                                                                                                                                                                     0.2s 
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker-compose ps
WARN[0000] /data/ltc/docker-compose.yaml: `version` is obsolete 
NAME             IMAGE                 COMMAND                  SERVICE    CREATED         STATUS         PORTS
ltc-lite-node-1   devocenter/litecoin   "/usr/local/bin/lite..."   bch-node   4 seconds ago   Up 2 seconds   0.0.0.0:9332-9333->9332-9333/tcp, :::9332-9333->9332-9333/tcp

7、验证节点同步情况

handlebars 复制代码
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker exec -it ltc-lite-node-1 /bin/bash
#获取最新同步区块的信息
root@0d354a8aae19:/# curl --user root:123456  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:9332/
{"result":{"chain":"main","blocks":39048,"headers":2677088,"bestblockhash":"d8ce662813d1fd00356081a74f244de3537862200e6ca1981ff799d40b77dd0d","difficulty":0.640534438438908,"mediantime":1322339330,"verificationprogress":0.0008527834538067149,"initialblockdownload":true,"chainwork":"00000000000000000000000000000000000000000000000000002b182584c4d3","size_on_disk":369020539,"pruned":false,"softforks":{"bip34":{"type":"buried","active":false,"height":710000},"bip66":{"type":"buried","active":false,"height":811879},"bip65":{"type":"buried","active":false,"height":918684},"csv":{"type":"buried","active":false,"height":1201536},"segwit":{"type":"buried","active":false,"height":1201536},"taproot":{"type":"bip8","bip8":{"status":"defined","start_height":2161152,"timeout_height":2370816,"since":0},"active":false},"mweb":{"type":"bip8","bip8":{"status":"defined","start_height":2217600,"timeout_height":2427264,"since":0},"active":false}},"warnings":""},"error":null,"id":"curltest"}

# 获取最新同步到的区块数
root@0d354a8aae19:/# curl --user root:123456  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:9332/
{"result":39248,"error":null,"id":"curltest"}

#获取最新同步区块的信息
litecoin-cli --conf=/root/.litecoin/litecoin.conf getblockchaininfo
{
  "chain": "main",
  "blocks": 0,
  "headers": 455999,
  "bestblockhash": "12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2",
  "difficulty": 0.000244140625,
  "mediantime": 1317972665,
  "verificationprogress": 5.359866906187669e-09,
  "initialblockdownload": true,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000100010",
  "size_on_disk": 288,
  "pruned": false,
  "softforks": {
    "bip34": {
      "type": "buried",
      "active": false,
      "height": 710000
    },
    "bip66": {
      "type": "buried",
      "active": false,
      "height": 811879
    },
    "bip65": {
      "type": "buried",
      "active": false,
      "height": 918684
    },
    "csv": {
      "type": "buried",
      "active": false,
      "height": 1201536
    },
    "segwit": {
      "type": "buried",
      "active": false,
      "height": 1201536
    },
    "taproot": {
      "type": "bip8",
      "bip8": {
        "status": "defined",
        "start_height": 2161152,
        "timeout_height": 2370816,
        "since": 0
      },
      "active": false
    },
    "mweb": {
      "type": "bip8",
      "bip8": {
        "status": "defined",
        "start_height": 2217600,
        "timeout_height": 2427264,
        "since": 0
      },
      "active": false
    }
  },
  "warnings": ""
}

lite节点钱包设置密码

handlebars 复制代码
root@iZt4n6qi8yq5skigf2kwxwZ:/data/ltc# docker exec -it ltc-lite-node-1 /bin/bash
root@0d354a8aae19:/# litecoin-cli --conf=/root/.litecoin/litecoin.conf encryptwallet Lite@2024
相关推荐
CESS_Cloud1 天前
CESS 出席华盛顿区块链政策峰会:参与国家安全与数据隐私保护专题讨论
安全·阿里云·web3·去中心化·区块链
TianXuan_Chain3 天前
web3跨链桥协议-Nomad
web3·区块链·智能合约·跨链桥
CertiK3 天前
Web3.0安全开发实践:探索比特币DeFi生态中的PSBT
区块链
选择不变3 天前
慢牛提速经典K线形态-突破下跌起始位和回档三五线,以及徐徐上升三种形态
区块链·通达信指标公式·炒股技巧·短线指标·炒股指标
飞天阁3 天前
Hyperledger Fabric 2.x 环境搭建
运维·区块链·fabric
Sui_Network3 天前
Sui 基金会任命 Christian Thompson 为新任负责人
大数据·人工智能·物联网·区块链·智能合约
电报号dapp1193 天前
NFT交易所开发攻略:打造未来数字艺术品交易新平台
人工智能·去中心化·区块链·智能合约
Q8137574603 天前
中阳动态分散投资策略:构建多元化投资组合的科学路径
人工智能·区块链
BlockOne113 天前
如何用发链框架,快速构建一条区块链?
区块链
web3探路者3 天前
解锁未来:深入探索去中心化应用程序(DApps)的潜力与挑战
去中心化·区块链·dapp开发·blockchain·dapps开发·去中心化 产品开发·dapps