Running the Docker Container
Run the following command to start a Docker container:
docker run -d -p 9090:9090 -p 26657:26657 -p 26656:26656 -p 1317:1317 -v /path/to/hedge_data:/root/hedge --env-file /path/to/env-file --name hedge_node hedgeblock/berberis:v0.1
This Docker command performs several crucial actions:
- Maps the specified directory as the volume for Hedge data, ensuring data persistence.
- Opens various ports for different functionalities, including P2P connections, metrics, and HTTP RPC.
- Sets the container to run in detached mode (-d) with the specified name (--name hedge_node).
- Reads environment configurations from the provided file (--env-file).
- Utilizes the Hedge image from Docker Hub.
Volume Mounting
-v /path/to/hedge_data:/root/hedge: This part of the command mounts a volume from your host machine to the container. Replace /path/to/hedge_data with the absolute path to the directory on your machine where you want to store blockchain data and configurations. The directory /root/hedge inside the container will store the data.
When running the Hedge blockchain node using Docker, it's recommended to use volumization to ensure data persistence. Docker volumes allow you to store data outside the container, making it easier to manage and persist data even if the container is stopped or removed.
Environment File
--env-file /path/to/your/env/file: This part of the command specifies the location of the environment file. Replace /path/to/your/env/file with the absolute path to your environment file (e.g., .env).
The env file should contain essential configurations for the Hedge blockchain node, including port settings, gas prices, node identity, and Swagger documentation enablement.
Verify Node Functionalities
To confirm that your node is operating as expected, inspect the Docker logs by running the following:
# List all running containers to get the container ID or name
docker ps
# View the logs of the Hedge blockchain node container (replace 'hedge_node' with your container ID or name)
docker logs -f hedge_node
The -f flag enables real-time logging, providing continuous updates on the node's activities.
Access Container's Shell
To access the container's shell and run various commands inside your Hedge Node Docker container, use the following command:
docker exec -it <hedge_node> sh
Replace <hedge_node> with your container ID or name