Skip to content

strophy/docker-dash-core

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nmarley/dashcore

A Dash Core docker image.

nmarley/dashcore nmarley/dashcore

Tags

Picking the right tag

  • nmarley/dashcore:latest: points to the latest stable release available of Dash Core. Use this only if you know what you're doing as upgrading Dash Core blindly is a risky procedure.
  • nmarley/dashcore:<version>: based on a slim Debian image, points to a specific version branch or release of Dash Core. Uses the pre-compiled binaries which are fully tested by the Dash Core team.
  • nmarley/dashcore:<version>-alpine: based on Alpine Linux with Berkeley DB 4.8 (cross-compatible build), points to a specific version branch or release of Dash Core. Uses a simple, resource efficient Linux distribution with security in mind, but is not officially supported by the Dash Core team. Use at your own risk.

What is Dash Core?

Dash Core is a reference client that implements the Dash protocol for remote procedure call (RPC) use. It is also the first Dash client in the network's history. Learn more about Dash Core on the Dash Developer Reference docs.

Usage

How to use this image

This image contains the main binaries from the Dash Core project - dashd, dash-cli and dash-tx. It behaves like a binary, so you can pass any arguments to the image and they will be forwarded to the dashd binary:

❯ docker run --rm -it nmarley/dashcore \
  -printtoconsole \
  -regtest=1 \
  -rpcallowip=172.17.0.0/16 \
  -rpcauth='foo:7d9ba5ae63c3d4dc30583ff4fe65a67e$9e3634e81c11659e3de036d0bf88f89cd169c1039e6e09607562d54765c649cc'

Note: learn more about how -rpcauth works for remote authentication.

By default, dashd will run as user dash for security reasons and with its default data dir (~/.dashcore). If you'd like to customize where dashcore stores its data, you must use the DASH_DATA environment variable. The directory will be automatically created with the correct permissions for the dash user and dashcore automatically configured to use it.

❯ docker run --env DASH_DATA=/var/lib/dashcore --rm -it nmarley/dashcore \
  -printtoconsole \
  -regtest=1

You can also mount a directory in a volume under /home/dash/.dashcore in case you want to access it on the host:

❯ docker run -v ${PWD}/data:/home/dash/.dashcore -it --rm nmarley/dashcore \
  -printtoconsole \
  -regtest=1

You can optionally create a service using docker-compose:

dashcore:
  image: nmarley/dashcore
  command:
    -printtoconsole
    -regtest=1

Using RPC to interact with the daemon

There are two communications methods to interact with a running Dash Core daemon.

The first one is using a cookie-based local authentication. It doesn't require any special authentication information as running a process locally under the same user that was used to launch the Dash Core daemon allows it to read the cookie file previously generated by the daemon for clients. The downside of this method is that it requires local machine access.

The second option is making a remote procedure call using a username and password combination. This has the advantage of not requiring local machine access, but in order to keep your credentials safe you should use the newer rpcauth authentication mechanism.

Using cookie-based local authentication

Start by launch the Dash Core daemon:

❯ docker run --rm --name dash-server -it nmarley/dashcore \
  -printtoconsole \
  -regtest=1

Then, inside the running dash-server container, locally execute the query to the daemon using dash-cli:

❯ docker exec --user dash dash-server dash-cli -regtest getmininginfo

{
  "blocks": 0,
  "currentblocksize": 0,
  "currentblockweight": 0,
  "currentblocktx": 0,
  "difficulty": 4.656542373906925e-10,
  "errors": "",
  "networkhashps": 0,
  "pooledtx": 0,
  "chain": "regtest"
}

In the background, dash-cli read the information automatically from /home/dash/.dashcore/regtest/.cookie. In production, the path would not contain the regtest part.

Using rpcauth for remote authentication

Before setting up remote authentication, you will need to generate the rpcauth line that will hold the credentials for the Dash Core daemon. You can either do this yourself by constructing the line with the format <user>:<salt>$<hash> or use the official rpcuser.py script to generate this line for you, including a random password that is printed to the console.

Note: This is a Python 3 script. use [...] | python3 - <username> when executing on macOS.

Example:

❯ curl -sSL https://raw.githubusercontent.com/dashpay/dash/master/share/rpcuser/rpcuser.py | python - <username>

String to be appended to dash.conf:
rpcauth=foo:7d9ba5ae63c3d4dc30583ff4fe65a67e$9e3634e81c11659e3de036d0bf88f89cd169c1039e6e09607562d54765c649cc
Your password:
qDDZdeQ5vw9XXFeVnXT4PZ--tGN2xNjjR4nrtyszZx0=

Note that for each run, even if the username remains the same, the output will be always different as a new salt and password are generated.

Now that you have your credentials, you need to start the Dash Core daemon with the -rpcauth option. Alternatively, you could append the line to a dash.conf file and mount it on the container.

Let's opt for the Docker way:

❯ docker run --rm --name dash-server -it nmarley/dashcore \
  -printtoconsole \
  -regtest=1 \
  -rpcallowip=172.17.0.0/16 \
  -rpcauth='foo:7d9ba5ae63c3d4dc30583ff4fe65a67e$9e3634e81c11659e3de036d0bf88f89cd169c1039e6e09607562d54765c649cc'

Two important notes:

  1. Some shells require escaping the rpcauth line (e.g. zsh), as shown above.
  2. It is now perfectly fine to pass the rpcauth line as a command line argument. Unlike -rpcpassword, the content is hashed so even if the arguments would be exposed, they would not allow the attacker to get the actual password.

You can now connect via dash-cli or any other compatible client. You will still have to define a username and password when connecting to the Dash Core RPC server.

To avoid any confusion about whether or not a remote call is being made, let's spin up another container to execute dash-cli and connect it via the Docker network using the password generated above:

❯ docker run -it --link dash-server --rm nmarley/dashcore \
  dash-cli \
  -rpcconnect=dash-server \
  -regtest \
  -rpcuser=foo\
  -stdinrpcpass \
  getbalance

Enter the password qDDZdeQ5vw9XXFeVnXT4PZ--tGN2xNjjR4nrtyszZx0= and hit enter:

0.00000000

Note: under Dash Core < 0.14.x, (future change to be backported) use -rpcpassword="qDDZdeQ5vw9XXFeVnXT4PZ--tGN2xNjjR4nrtyszZx0=" instead of -stdinrpcpass.

Done!

Exposing Ports

Depending on the network (mode) the Dash Core daemon is running as well as the chosen runtime flags, several default ports may be available for mapping.

Ports can be exposed by mapping all of the available ones (using -P and based on what EXPOSE documents) or individually by adding -p. This mode allows assigning a dynamic port on the host (-p <port>) or assigning a fixed port -p <hostPort>:<containerPort>.

Example for running a node in regtest mode mapping JSON-RPC/REST (19898) and P2P (19899) ports:

docker run --rm -it \
  -p 19898:19898 \
  -p 19899:19899 \
  nmarley/dashcore \
  -printtoconsole \
  -regtest=1 \
  -rpcallowip=172.17.0.0/16 \
  -rpcauth='foo:7d9ba5ae63c3d4dc30583ff4fe65a67e$9e3634e81c11659e3de036d0bf88f89cd169c1039e6e09607562d54765c649cc'

To test that mapping worked, you can send a JSON-RPC curl request to the host port:

curl --data-binary '{"jsonrpc":"1.0","id":"1","method":"getnetworkinfo","params":[]}' http://foo:[email protected]:18443/

Mainnet

  • JSON-RPC/REST: 9998
  • P2P: 9999

Testnet

  • Testnet JSON-RPC: 19998
  • P2P: 19999

Regtest

  • JSON-RPC/REST: 19898 (since 0.14.1+, otherwise 18332)
  • P2P: 19899 (since 0.14.1+, otherwise 19994)

Devnet

  • JSON-RPC/REST: 19798 (since 0.14.1+, otherwise 19998)
  • P2P: 19799 (since 0.14.1+, otherwise 19999)

Docker

This image is unofficially supported on Docker version 19.03, with support for all versions provided on a best-effort basis.

License

License information for the software contained in this image.

License information for the nmarley/docker-dash-core docker project.

Releases

No releases published

Packages

No packages published

Languages

  • Dockerfile 78.2%
  • Shell 21.8%