Forest in Dockerπ²β€οΈπ
Prerequisitesβ
- Docker engine installed and running. Forest containers are confirmed to run on
the following engines:
- Docker Engine (Community) on Linux,
- Docker for macOS
- Docker on Windows Subsystem for Linux 2(WSL2)
Native images are available for the following platform/architecture(s):
linux/arm64
linux/amd64
The images will work out-of-the box on both Intel processors and macOS with M1 / M2.
Tagsβ
For the list of all available tags please refer to the Forest packages.
Currently, the following tags are produced:
latest
- latest stable release,latest-fat
- latest stable release with necessary downloadable files preloaded,edge
- latest development build of themain
branch,edge-fat
- latest development build of themain
branch with necessary downloadable files preloaded,date-digest
e.g.,2023-02-17-5f27a62
- all builds that landed on themain
branch,date-digest-fat
e.g.,2023-02-17-5f27a62-fat
- all builds that landed on themain
branch with necessary downloadable files preloaded,- release tags, available from
v0.7.0
orv0.7.0-fat
onwards.
Security recommendationsβ
- We strongly recommend running the docker daemon in rootless mode
(installation instructions),
or running the daemon-less docker alternative
podman
(installation instructions) with non-root user and putalias docker = podman
(or manually replace thedocker
commands withpodman
in below instructions)
Performance recommendationsβ
- We recommend lowering the swappiness kernel parameter on Linux to 1-10 for
long running forest node by doing
sudo sysctl -w vm.swappiness=[n]
.
Example usagesβ
List available flags and/or commandsβ
# daemon
β― docker run --init -it --rm ghcr.io/chainsafe/forest:latest --help
# cli
β― docker run --init -it --rm --entrypoint forest-cli ghcr.io/chainsafe/forest:latest --help
# tool
β― docker run --init -it --rm --entrypoint forest-tool ghcr.io/chainsafe/forest:latest --help
# wallet tool
β― docker run --init -it --rm --entrypoint forest-wallet ghcr.io/chainsafe/forest:latest --help
Also see the CLI documentation for more details about commands and their usage.
Run a Forest node with custom environment variablesβ
β― docker run --init -it --rm --name forest --env <key>=<value> ghcr.io/chainsafe/forest:latest --chain calibnet --auto-download-snapshot
Check Forest environment variables documentation for more details.
Create a Forest node running calibration network. Then list all connected peers.β
# interactive mode
β― docker run --init -it --rm --name forest ghcr.io/chainsafe/forest:latest --chain calibnet --auto-download-snapshot
# non-interactive mode
β― docker run --init --name forest ghcr.io/chainsafe/forest:latest --chain calibnet --auto-download-snapshot
Note: watchtower is a great tool for keeping the forest image up-to-date, automagically, check instructions.
then in another terminal (sample output)
β― docker exec forest forest-cli net peers
12D3KooWAh4qiT3ZRZgctVJ8AWwRva9AncjMRVBSkFwNjTx3EpEr, [/ip4/10.0.2.215/tcp/1347, /ip4/52.12.185.166/tcp/1347]
12D3KooWMY4VdMsdbFwkHv9HxX2jZsUdCcWFX5F5VGzBPZkdxyVr, [/ip4/162.219.87.149/tcp/30141, /ip4/162.219.87.149/tcp/30141/p2p/12D3KooWMY4VdMsdbFwkHv9HxX2jZsUdCcWFX5F5VGzBPZkdxyVr]
12D3KooWFWUqE9jgXvcKHWieYs9nhyp6NF4ftwLGAHm4sCv73jjK, [/dns4/bootstrap-3.calibration.fildev.network/tcp/1347]
Use a shared volume to utilize across different Forest imagesβ
Create the volume
docker volume create forest-data
Now, whenever you create a new Forest container, attach the volume to where the
data is stored /root/.local/share/forest
.
β― docker run --init -it --rm \
--ulimit nofile=8192 \
--volume forest-data:/root/.local/share/forest \
--name forest ghcr.io/chainsafe/forest:latest --chain calibnet
--auto-download-snapshot
Export the calibnet snapshot to the host machineβ
Assuming you have forest
container already running, run:
β― docker exec forest forest-cli --chain calibnet snapshot export
Export completed. Snapshot located at forest_snapshot_calibnet_2023-02-17_height_308891.car
Copy the snapshot to the host
β― docker cp forest:/home/forest/forest_snapshot_calibnet_2023-02-17_height_308891.car .