Get Started with Bitcoin Using Docker

Posted on Thu 30 November 2017 in bitcoin

Like me, you're probably more comfortable on a CLI. Here's a quick way to use docker to set up a Bitcoin Wallet and trade Bitcoin for free on Testnet with Electrum. You can use the same tools to manage your real Bitcoin wallet too.


Make sure you have Docker for your OS ( Mac, Windows, Linux)

Run the electrum-cli docker image

Electrum is a python-based Docker wallet with a both a gui and good cli. I've put together electrum-cli, a lightweight Alpine-linux Docker image with Electrum signed and installed with jq.

docker run -it tonymet/electrum-cli

Create a wallet

First , create the wallet & testnet wallet.

# electrum requires first a real wallet. We won't use it afterward
$ electrum create
# create testnet wallet
$ electrum --testnet create

Now start the daemon in the background. This manages network connections

$ electrum --testnet daemon&
# tell the daemon to load your testnet wallet
$ electrum --testnet daemon load_wallet
# electrum --testnet getbalance | jq .confirmed

At this point your wallet is loaded

Receive Some Bitcoin from Testnet

Get your wallet address

# use jq to get your first address.
$ electrum --testnet listaddresses |jq .[0]

Visit a popular → Bitcoin Testnet Faucet to get some coin. Enter your testnet wallet address there. They will give you a txid for you to pull using electrum gettransaction

Now fetch the transaction

$ electrum --testnet gettransaction TRANSACTION_ID
# get the latest transaction
$ electrum --testnet history|jq '.[-1]'

  "confirmations": 1,
  "date": "2017-12-01 01:42",
  "height": 1251680,
  "input_addresses": [
  "label": "",
  "output_addresses": [
  "timestamp": 1512092568,
  "txid": "xxxxx",
  "value": "2.29999999"

Now you should have some real Bitcoin on Testnet! Let's check our balance using electrum getbalance and jq

$ electrum --testnet getbalance | jq .confirmed

Security Concerns

Even though this is a testnet wallet, let's always keep security top of mind. For one, you may accidentally push your image to a docker repo and expose your wallet. Also, your docker images are not (yet) encrypted, so any wallet info in these images should be considered compromised.

Next Steps

In upcoming sessions we'll look into securing your wallet using encrypted images and docker volumes.