Skip to main content

Starting the node using docker-compose

Table of Contents

Introduction

You can also start your node using docker-compose, which is even easier than starting your node using conventional Docker commands described here.

Setting up the environment

You need to have docker-compose package installed on your machine. If you don't have this package installed, run the following command in terminal for:

  1. root user:
apt-get -y install docker-compose
  1. Normal user:
sudo apt-get -y install docker-compose
Attention

By implementing this way of starting the node we assume that

  • node.config,
  • genesis.txt,
  • SSL keys,
  • db and log directories

are present and stored in /opt/thepower/ like described in Docker and source manuals.

The following tree describes the directories and files in them:

tree

hostname here is an example. Please, replace it with the hostname specified in your node.config file.

  1. Go to /opt/thepower:
cd /opt/thepower
  1. Create docker-compose.yml file with the following code:
docker-compose.yml
version: "3.3"

services:

tpnode:
restart: unless-stopped
container_name: tpnode
image: thepowerio/tpnode
volumes:
- type: bind
source: /opt/thepower/node.config
target: /opt/thepower/node.config
read_only: true
- type: bind
source: /opt/thepower/genesis.txt
target: /opt/thepower/genesis.txt
read_only: true
- type: bind
source: /opt/thepower/db
target: /opt/thepower/db
- type: bind
source: /opt/thepower/log
target: /opt/thepower/log
ports:
- 1080:1080
- 1443:1443
- 1800:1800

watchtower:
restart: unless-stopped
container_name: watchtower
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 3600 --cleanup
Note

This file also allows watchtower to automatically update the node.

Starting the node

To start the node:

  1. Ensure, that you are in /opt/thepower directory. If not, run:
cd /opt/thepower
  1. Run the following command:
docker-compose up -d

Stopping the node

  1. Ensure, that you are in /opt/thepower directory. If not, run:
cd /opt/thepower
  1. Run the following command:
docker-compose down