Lisk Core Docker Administration

This section details how to work with a Docker-based Lisk Core installation. Listed below are available basic commands which can be used to manage your Docker-based Lisk node. For more details, see each commands reference below. A summary of all commands and associated flags has been provided for advanced users.

Basic Commands

Below commands must be executed inside the docker directory of your Lisk Core installation.

Status

docker-compose ps

Start

docker-compose start lisk

Stop

docker-compose stop lisk

Restart

docker-compose restart lisk

Reset / Coldstart

make coldstart

Logs

docker-compose logs

Run a command

To run a command in the container where your Lisk Core node is running, use docker-compose exec.

docker-compose exec lisk curl "http://localhost:7000/api/node/status" --header "accept: application/json" (1)
1 Example: How to make an API request to your node

Configuration

Lisk Core normally gets configured by providing a suited configuration file. But this isn’t convenient in a Docker installation. Instead, one can use environment variables to change values in the configuration. To do so, open the .env file, that you created during docker installation, and adjust the values to your needs. All names of the environment variables start with ENV prefix.

Advanced configuration

For advanced configuration, open docker/docker-compose.override.yml. Configuration variables always start with LISK_ and are mapped to their path in config.json. These can be changed directly in the file if needed. For example, the value of redis.db.host can be changed by setting the LISK_REDIS_DB_HOST environment variable. If you are unsure what variable name to use, refer to the list of command line options.

After editing the variables, reinitialize Lisk Core. It will read docker-compose.yml and your customized docker-compose.override.yml file:

docker-compose up -d

Examples

Use redis for caching

Caching using Redis can be enabled with the docker-compose.redis.yml file, e.g.:

When specifying additional docker-compose files like docker-compose.redis.yml, they need to be chained in the correct order by using the -f flag like below:

docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.redis.yml up -d

Note that the variables inside docker-compose.redis.yml can be defined in docker-compose.override.yml as well.

Do not expose ports:

version: "3"
services:

  lisk:
    ports:
      - ${ENV_LISK_HTTP_PORT}
      - ${ENV_LISK_WS_PORT}

Increase log level to debug, enable public API:

version: "3"
services:

  lisk:
    environment:
      - LISK_CONSOLE_LOG_LEVEL=debug
      - LISK_API_PUBLIC=true

Add forging delegates and whitelist IPs:

version: "3"
services:

  lisk:
    environment:
      - LISK_FORGING_DELEGATES=publicKey1|encryptedPassphrase1,publicKey2|encryptedPassphrase2
      - LISK_API_WHITELIST=127.0.0.1,172.17.0.1
      - LISK_FORGING_WHITELIST=127.0.0.1,172.17.0.1

Sync from a snapshot

Syncing from the Genesis block can take a lot of time as the whole blockchain needs to be downloaded and validated. To accelerate this process, it is recommended to sync your node from a snapshot. Snapshots are database dumps of the Blockchain on a certain blockheight. While syncing from a snapshot, your node will only validate blocks with higher blockheight than the one of the used snapshot.

Lisk provides official snapshots that will be used during the automated synching process. If you want to use third-party snapshots make sure they come from a reliable source.

Automated

cd lisk/docker  (1)
make coldstart  (2)
1 navigate into docker directory
2 will download and restore a blockchain snapshot for you

Manually

The command block in the example below will perform the process. The URL can be substituted for another blockchain.db.gz snapshot file if desired.

Example

For this example we expect the environment variables equal the following values:

  • ENV_LISK_NETWORK=mainnet

  • ENV_LISK_DB_DATABASE=lisk

cd lisk/docker            (1)
curl --output main_blockchain.db.gz https://downloads.lisk.io/lisk/main/blockchain.db.gz  (2)
docker-compose up -d      (3)
docker-compose stop lisk  (4)
docker-compose start db   (5)
docker-compose -f docker-compose.yml -f docker-compose.make.yml run --rm db-task dropdb --if-exists lisk (6)
docker-compose -f docker-compose.yml -f docker-compose.make.yml run --rm db-task createdb lisk           (7)
gzip --decompress --to-stdout main_blockchain.db.gz | docker-compose -f docker-compose.yml -f docker-compose.make.yml run --rm db-task psql >/dev/null (8)
docker-compose start lisk (9)
1 navigate into docker directory
2 download and save the blockchain snapshot
3 initialize Lisk and postgreSQL
4 stop Lisk Core
5 start postgreSQL
6 drop old database
7 create fresh database
8 import snapshot into database
9 start Lisk container