Tuesday 3 July 2018

Run Bitcoind as a Docker Service

This is a continuation from the previous blog article http://embedded-design-vic.blogspot.com/2018/06/run-bitcoind-in-docker-container.html


1) append this line to the Dockerfile,
   so that bitcoind is started auto when container image is run
ENTRYPOINT ./bin/bitcoind -datadir=node -daemon && /bin/bash

2) rebuild the image
 docker build -t bitcoin-docker .

3) tag image for upload to registry
docker tag <image> username/repository:tag

4) upload tagged image to registry
docker push username/repository:tag 

5) add a docker-compose.yml file
version: "3"
services:
  web:
    # replace username/repo:tag with your name and image details
    image: chaintope99/bitcoin:dev
    deploy:
      replicas: 5
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
      restart_policy:
        condition: on-failure
    ports:
      - "5000:12001"
    networks:
      - webnet
networks:
  webnet:

6) init the swarm, swarm is a group of machines and joined as cluster
swarm manager uses several strategies to run containers.
docker swarm init

7) run the specified docker compose file
docker stack deploy -c <composefile> <appname>

8) use curl to access the dockerised bitcoind service
curl --user username:password --data '{"method": "getinfo"}' http://127.0.0.1:5000