Run Anemos using Docker
Preface
Docker is a tool that simplifies the process of creating, deploying, and running applications using containers. With containers, developers can bundle all the necessary parts of an application, including libraries and dependencies, and deploy them as a single package.
In this document, we will guide you on how to run Anemos using Docker, step by step.
Prerequisites
Before running Anemos with Docker, ensure that you have a clear understanding of
how anemos-daemon and anemos-wallet works.
Then you need to install docker in your system.
If you are using Windows please make sure you have installed WSL.
Docker Images
The Anemos docker images are available at Docker Hub. You can pull the latest image with this command:
docker pull anemos/anemosInitializing the Node
Now you need to create a wallet and setup a working directory for your node. A working directory is a place where you save blockchain data and wallets. Open the Terminal and run the following command:
docker run -it --rm -v ~/anemos:/root/anemos anemos/anemos anemos-daemon initThis command creates your wallet and setup the working directory at ~/anemos.
docker run -it --rm -v %USERPROFILE%\anemos:/root/anemos anemos/anemos anemos-daemon initThis command creates your wallet and setup the working directory at C:\Users\<USER_NAME>\anemos.
Here’s an explanation of the Docker flags:
-it: Makes the Docker container interactive for command-line interaction.--rm: Cleans up the temporary environment automatically when you’re done.-v <local_dir>:<container_dir>: Allows to choose where to store the Anemos data.
Always keep a paper backup of your seed phrase in a safe and secure location. If someone gains access to your seed phrase, they can gain full control over your wallet and funds.
Importing data (Optional)
To speed up the syncing process, you can import a snapshot of the blockchain from a centralized server. This will start your node in Pruned Mode:
docker run -it --rm -v ~/anemos:/root/anemos anemos/anemos anemos-daemon importdocker run -it --rm -v %USERPROFILE%\anemos:/root/anemos anemos/anemos anemos-daemon importStarting with version 1.4.0, Anemos supports Pruned Mode. In this mode, you don’t need to download the entire blockchain; instead, you can download recent blocks from the last 10 days. This significantly speeds up the syncing process.
Running the Node
Now you can start the node and sync with the network. Run the following command in the Terminal:
docker run -it -d -v ~/anemos:/root/anemos \
-p 21888:21888 \
-p 21888:21888/udp \
-p 50051:50051 \
-p 8080:8080 \
--name anemos anemos/anemos anemos-daemon start --password <WALLET_PASSWORD>docker run -it -d -v %USERPROFILE%\anemos:/root/anemos ^
-p 21888:21888 ^
-p 21888:21888/udp ^
-p 50051:50051 ^
-p 8080:8080 ^
--name anemos anemos/anemos anemos-daemon start --password {WALLET_PASSWORD}This command creates and runs a Docker container named “anemos”. Here’s an explanation of the Docker flags:
-p <host_port>:<container_port>: Maps a port from your host machine to a port in the Docker container.-d: Starts the container in detached mode. The container runs in the background.--name <NAME>: Allows you to assign a custom name to a container.
Default Ports
The default network ports in Anemos are defined as follows. It is recommended not to change these default ports:
- P2P port is
21888. P2P supports both UDP and TCP protocols. - gRPC port is
50051. The gRPC module is enabled by default for localhost. - gRPC-gateway port is
8080. The gRPC-gateway is disabled by default. - JSON-RPC port is
8545. The JSON-RPC service is disabled by default. - Nanomsg port is
40899. The Nanomsg service is disabled by default.
Essential Commands
You can manage the Anemos Docker container with these essential commands:
Stop the container:
docker stop anemosThis command gracefully stops the “anemos” container.
Start the container:
docker start anemosThis command starts the Anemos Docker container.
View Container Logs:
To check the logs:
docker logs anemos --tail 1000 -fHere’s an explanation of the Docker flags:
--tail 1000: Displays the last 1000 lines of logs.-f: Shows the log output in real-time.
Remove Docker container:
If you want to upgrade the node, you should first remove the current container:
docker rm anemosAfter removing the Anemos Docker container, you can create and run a new version, as explained above.
Enabling IPv6
By default, Docker only supports IPv4. IPv6 is only supported on Linux systems. Enabling IPv6 can help you improve connectivity and security. To enable IPv6 for Docker, follow the official documentation here.
Managing Wallet Using Docker
You can use Anemos Docker to manage the wallet. For example, you can check the balance of your wallet as shown below:
docker run -it --rm -v ~/anemos:/root/anemos anemos/anemos anemos-wallet address all --balance --stakedocker run -it --rm -v %USERPROFILE%\anemos:/root/anemos anemos-wallet address all --balance --stakeExample docker compose
Here is example docker compose for run anemos node.
version: '3'
services:
anemos:
hostname: anemos
container_name: anemos
image: anemos/anemos:latest
command: anemos-daemon start -w /anemos
restart: always
volumes:
- ./anemos:/anemos
ports:
- 21888:21888 # required: p2p port
- 50051:50051 # optional: access to port grpc on host
- 8080:8080 # optional: access to port grpc gateway on host
- 8545:8545 # optional: access to port json rpc on host
- 8081:80 # optional: access to port http on host