LoginSignup
6
3

More than 5 years have passed since last update.

Dockerfileを使ってbitcoindをコンテナ化してみた

Last updated at Posted at 2017-06-16

環境を汚すことなくbitcoindを使いたかったので、bitcoindをコンテナ化してみました。

1.Dockerfileの作成

まずは、Dockerfileを作成。
ubuntuのイメージに対し、以下の処理を追加します。

  • ビルド環境用パッケージのインストール
  • boost関連パッケージのインストール
  • bitcoinソースコードのクローン
  • bitcoinソースコードのコンパイル
  • bitcoindが使用するポートの開放
Dockerfile
FROM ubuntu:16.04

RUN  \
  apt-get update && \
  apt-get -y install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils \
  libboost-all-dev \
  libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev \
  software-properties-common && \
  add-apt-repository ppa:bitcoin/bitcoin && \
  apt-get update && \
  apt-get -y install libdb4.8-dev libdb4.8++-dev

RUN  \
  apt-get -y install git && \
  git clone https://github.com/bitcoin/bitcoin.git

WORKDIR bitcoin

RUN   \
  ./autogen.sh && \
  ./configure --without-gui && \
  make && \
  make install

EXPOSE 8332 8333 18332 18333

2.dockerイメージの作成

次に、dockerイメージを作成。
ビルドに時間がかかる。。30分くらい待機。
docker build -t hogehoge:docker-bitcoind .

3.dockerコンテナの起動&接続

そして、dockerコンテナを起動&接続。
docker run -it hogehoge:docker-bitcoind bash

4.bitcoind動作確認

とりあえず、ローカル環境のテストネットを起動。
bitcoind -regtest -deamon

なんかプロンプトが返ってこないので、別ターミナルでコンテナに接続しブロックを生成をしてみる。
bitcoin-cli -regtest generete 101

とりあえず、ちゃんと動くっぽい。
ここから先は、下のサイトを使って勉強してみるかなー。

参考にさせていただきました

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3