Docker image commands

This section details how to work with a Docker image-based Lisk Core installation, and covers the available basic commands which can be used to manage your Docker image-based Lisk node. For more information, please see all the command references listed below. In addition, a summary of all commands and associated flags is also provided here for advanced users.

Basic commands

The following commands listed below 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, please use the following: 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. However it should be noted that this is not convenient in a Docker image installation. Instead, environment variables can be used to change values in the configuration. To perform this, open the .env file, that was created during the Docker image installation, and adjust the values to your requirements. All names of the environment variables start with ENV_ prefix.

Advanced configuration

For advanced configuration, please open the following: 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 necessary. 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, re-initialize Lisk Core. It will read both the 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.

Please note that 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 as shown in the command below:

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

In addition, please note that the variables inside docker-compose.redis.yml can be defined in docker-compose.override.yml as well.

Do not expose ports:

(Please see: docker-compose 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

Synchronizing from the genesis block can take a considerable amount of time as the whole blockchain needs to be downloaded and validated. To accelerate this process, it is recommended to synchronize your node from a snapshot. Snapshots are database dumps of the blockchain at a certain block height. While synchronizing from a snapshot, your node will only validate the blocks with a higher block height than the one of the previously used snapshot.

Lisk provides official snapshots that will be used during the automated synchronization process. If you wish to use third-party snapshots, please ensure they are from a reliable source.

Automated

cd lisk/docker  (1)
make coldstart  (2)
1 This navigates into the docker directory.
2 This will download and restore a blockchain snapshot.

Manually

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

Example

In this following example it is expected that the environment variables will equal the following values listed below:

  • 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 Navigates into the docker directory.
2 Downloads and saves the blockchain snapshot.
3 Initializes Lisk and postgreSQL.
4 Stops Lisk Core.
5 Starts postgreSQL.
6 Drops the old database.
7 Creates a fresh database.
8 Imports a snapshot into the database.
9 Starts the Lisk container.