Bitcoin Forum
May 31, 2024, 12:14:25 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Linux Container for bitcoin  (Read 2563 times)
coinrevo (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
December 17, 2013, 06:55:37 PM
Last edit: December 18, 2013, 02:36:54 PM by coinrevo
 #1

Below follows a linux container for bitcoind. Feel free to use this for building bitcoind in a lightweight VM (aka container) without effort. You only need docker installed, the container will build itself without further steps. This is for testing/development only, not for production.  IMO this is the easiest to get starting developing, as all dependencies are resolved. You only need linux and docker 0.7.

Docker.io is a new technology which allows to use Linux containers in a very easy way. Since version 0.7 docker is available for all linux distributions. One way to think about docker is to think of it as lightweight Virtual Machines. Essentially this allows for easily moving any software between machines. As bitcoind is really architected as a full P2P node, this is more useful for libbitcoin, btcd, or any software indented to run on servers as well, but there would be benefits for bitcoind as well.

One immediate benefit is that all any OS dependencies of libraries are packaged in the containers. This is similar to shipping around VM's containing all dependencies, however full VM's have a much to big load to handle. With docker this becomes very lightweight over the network.

Here is a Dockerimage for the bitcoin daemon (bitcoind). I might put this into a github a bit later.

Quote
#put this in a Dockerfile
#------------------------------------------
# Docker bitcoin
# v0.0.1
#
# a basic container for running bitcoind
# requires docker 0.7 and nothing else
#
# !!caveat emptor!! don't use this for money you care about unless you know what you are doing
#------------------------------------------
#
# we are using ubuntu 13.04 - we need a recent ubuntu version
# currently from a foreign source. this has be to rebuild from scratch for secruity reasons later
# looks similar this, but this gist breaks though
# https://gist.github.com/aputs/6247216
#
# general info on how to build images
# http://docs.docker.io/en/latest/use/baseimages/
#
# TODO
# * change password input method
# * build ubuntu from scratch not foreign source
# * use BerkeleyDB 4.8, so no errros appear
# * dockerify other independent implementations, such as btcd and libbitcoin
#------------------------------------------

FROM boxcar/raring

#OS libs
#ubuntu 13 has these
#RUN apt-get install -y git
#RUN apt-get install -y build-essential

RUN apt-get install -y libssl-dev
RUN apt-get install -y libboost-all-dev
RUN apt-get install -y dh-autoreconf

RUN apt-get install -y ccache
RUN apt-get install -y pkg-config

#undocument issues with bitcoin unix install
RUN apt-get install -y libdb++-dev
RUN apt-get install -y libprotobuf-dev

#now we build bitcoin from source
RUN cd /home
RUN mkdir bitcoin; cd bitcoin
RUN git clone git://github.com/bitcoin/bitcoin.git /home/bitcoin
RUN /bin/bash /home/bitcoin/autogen.sh

#need to fix BerkeleyDB to get rid of the 1st flag
RUN cd /home/bitcoin && ./configure --with-incompatible-bdb --without-qt
RUN cd /home/bitcoin && make

#we've build the binary, now copy it so we can execute anywhere in the container
RUN cp /home/bitcoin/src/bitcoind /usr/local/bin

#insert a RPC password
RUN /bin/mkdir $home/.bitcoin
RUN /bin/touch $home/.bitcoin/bitcoin.conf
#change password!
RUN /bin/echo -e "rpcuser=golem\nrpcpassword=qqqqqq" > $home/.bitcoin/bitcoin.conf


To build into a docker image do build -t bitcoind .

The "." refers to the current directory where the above Dockerfile lives.

So now we can then run the bitcoind in the container. This can be done from the host as well, instead of bin/bash'ing.

$ sudo docker run -i -t bitcoind:latest /bin/bash

inside the container

root@6c552ad974c6:/# bitcoind -daemon
Bitcoin server starting
root@6c552ad974c6:/# bitcoind getinfo
{
    "version" : 89900,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 2103,
    "timeoffset" : 0,
    "connections" : 2,
    "proxy" : "",
    "difficulty" : 1.00000000,
    "testnet" : false,
    "keypoololdest" : 1387305282,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "errors" : "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}
lest
Member
**
Offline Offline

Activity: 75
Merit: 10


View Profile
December 18, 2013, 04:08:02 PM
 #2

I think that using Bitcoin PPA would be faster and easier.
coinrevo (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
December 18, 2013, 06:46:15 PM
 #3

Running things in containers and natively in the host are worlds apart, as you can package everything in a container, that is it ships with the OS so to speak (without sending GB's of a VM over the wire). So if you imagine a much more modular approach to bitcoin software, this is very useful. I might have overstated the case for ease of development, and understated the power it brings to development. Currently bitcoind is very monolithic and packages OS libs in an old fashioned way. For instance you can't just change the underlying database, or network interface. Docker is ideal for managing such dependencies. Packet-managers are much less sophisticated. They have to be ported for every distro. In somes cases that's not even possible.
lest
Member
**
Offline Offline

Activity: 75
Merit: 10


View Profile
December 18, 2013, 09:55:25 PM
 #4

Yeah, definitely. But you can use this PPA in your Dockerfile instead of building from source. It's just my 2¢.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!