# 使用 Docker

{% hint style="danger" %}
如果你之前运行过 devnet 全节点或测试网节点，请先停止，防止端口冲突导致无法运行测试网验证者节点。

If you have run a devnet full node before, please stop it first to prevent port conflicts from running the testnet validator node.

请收藏本网址以获得最新教程！！！
{% endhint %}

### 节点要求

* CPU: 8 核 16 线程
* RAM：32GB
* 存储：300 GB
* 带宽：1 Gbps

详细要求请参阅 [节点要求](#jie-dian-yao-qiu)

### 安装 Docker 和 docker-compose（Install Docker and docker-compose）

```shell
# Install Docker
wget -O get-docker.sh https://get.docker.com 
sudo sh get-docker.sh
rm -f get-docker.sh

# Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

```

### 创建目录（Create Directory）

```bash
sudo mkdir -p ~/aptos-node/testnet3 && cd ~/aptos-node/testnet3

```

### 生成密钥对（节点所有者密钥、共识密钥和网络密钥）（Generate private keys）

```bash
sudo docker run --rm \
  -v $(pwd)/keys:/data/aptos-cli \
  jiangydev/aptos-cli:v0.3.1 \
  aptos genesis generate-keys --output-dir /data/aptos-cli

```

![](https://837065856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVfhRe3oc2wVpOxYrh1V%2Fuploads%2Fn5BfH9XoKmZoLNjsk7EO%2Fimage.png?alt=media\&token=4473eb69-57d5-4d96-9016-d3cdb64d4ef6)

### 下载编排文件（Download files）

```bash
sudo wget -O docker-compose.yaml https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/aptos-node/docker-compose.yaml
sudo wget -O validator.yaml https://raw.githubusercontent.com/aptos-labs/aptos-core/main/docker/compose/aptos-node/validator.yaml

```

### 生成验证者配置（Generate Validator Info）

{% hint style="warning" %}
只需要修改以下信息：（Only need to modify these config）

* 您的节点名称\<your-node-name>
* 验证者节点IP或DNS域名:端口\<your-vlidator-node-ip:port>
* 全节点IP或DNS域名:端口\<your-full-node-ip:port>，<mark style="color:red;">如果你要搭建全节点，这里要正确填写！！！</mark>

`MoveMove` 是我的节点名称（欢迎加入 MoveMove 社区） 😀（`MoveMove` is my node name）
{% endhint %}

```bash
sudo docker run --rm \
  -v $(pwd):/data/aptos-cli \
  jiangydev/aptos-cli:v0.3.1 \
  aptos genesis set-validator-configuration \
  --local-repository-dir /data/aptos-cli \
  --owner-public-identity-file /data/aptos-cli/keys/public-keys.yaml \
  --stake-amount 100000000000000 \
  --username 您的节点名称<your-node-name> \
  --validator-host 验证者节点IP或DNS域名:端口<your-vlidator-node-ip:port> \
  --full-node-host 全节点IP或DNS域名:端口<your-full-node-ip:port>
```

示例（Example）：

```bash
sudo docker run --rm \
  -v $(pwd):/data/aptos-cli \
  jiangydev/aptos-cli:v0.3.1 \
  aptos genesis set-validator-configuration \
  --local-repository-dir /data/aptos-cli \
  --owner-public-identity-file /data/aptos-cli/keys/public-keys.yaml \
  --username MoveMove \
  --validator-host 35.232.235.205:6180 \
  --full-node-host 35.232.235.205:6182 \
  --stake-amount 100000000000000

```

![](https://837065856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVfhRe3oc2wVpOxYrh1V%2Fuploads%2FB1D3BDHHIDSnTPzMfDjA%2Fimage.png?alt=media\&token=fff7e465-380d-4e4b-8738-c354362eb0d9)

### 生成 layout 文件（Generate layout YAML file）

{% hint style="warning" %}

* needn't modify the root key（官方文档中提及，不需要修改 root\_key）
* modify the node name（只需要修改 您的节点名称）
* The following command is a statement, please modify and execute after copying all of them.（下面的命令是一条语句，请全部<mark style="color:red;">复制后修改</mark>并执行）
  {% endhint %}

```shell
sudo bash -c "cat > layout.yaml" <<EOF
---
root_key: "D04470F43AB6AEAA4EB616B72128881EEF77346F2075FFE68E14BA7DEBD8095E"
users: ["您的节点名称<your-node-name>"]
chain_id: 43
allow_new_validators: false
epoch_duration_secs: 7200
is_test: true
min_stake: 100000000000000
min_voting_threshold: 100000000000000
max_stake: 100000000000000000
recurring_lockup_duration_secs: 86400
required_proposer_stake: 100000000000000
rewards_apy_percentage: 10
voting_duration_secs: 43200
voting_power_increase_limit: 20
EOF

```

示例：（Example）

```bash
sudo bash -c "cat > layout.yaml" <<EOF
---
root_key: "D04470F43AB6AEAA4EB616B72128881EEF77346F2075FFE68E14BA7DEBD8095E"
users: ["MoveMove"]
chain_id: 43
allow_new_validators: false
epoch_duration_secs: 7200
is_test: true
min_stake: 100000000000000
min_voting_threshold: 100000000000000
max_stake: 100000000000000000
recurring_lockup_duration_secs: 86400
required_proposer_stake: 100000000000000
rewards_apy_percentage: 10
voting_duration_secs: 43200
voting_power_increase_limit: 20
EOF

```

![](https://837065856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVfhRe3oc2wVpOxYrh1V%2Fuploads%2F0L2EBTQ3UVoeW9qM2rIb%2Fimage.png?alt=media\&token=4fc11b78-92b2-4446-82f9-bb06a8bea79f)

### 生成 genesis blob 和 waypoint（Generate genesis blob  and waypoint file）

```bash
sudo docker run --rm \
  -v $(pwd):/data/aptos-cli \
  jiangydev/aptos-cli:v0.3.1 \
  sh -c "rm -rf /data/aptos-cli/genesis.blob && rm -rf /data/aptos-cli/waypoint.txt && rm -rf /data/aptos-cli/framework.mrb && cp -r /framework.mrb /data/aptos-cli && aptos genesis generate-genesis --local-repository-dir /data/aptos-cli --output-dir /data/aptos-cli && rm -rf /data/aptos-cli/framework.mrb"

```

![](https://837065856-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVfhRe3oc2wVpOxYrh1V%2Fuploads%2FMB70K3rEzOAVcJxAX0EY%2Fimage.png?alt=media\&token=5c753faf-454e-4731-b147-ec78d51cfc1d)

### 启动节点（Run node）

```bash
sudo docker-compose pull
sudo docker-compose up -d

```

{% hint style="warning" %}
如果您的节点端口不通，请关闭服务器防火墙，并在云服务器提供商的安全策略中放行如下端口：

验证者节点（本教程只提供验证者节点搭建）：

* 80：validator REST API 端口；
* 6180：validator 的 peer 通信端口；
* 6181：fullnode 通信端口；
* 9101：validator 指标端口；

全节点：

* 6182：full node 的 peer 信端口；
* 80：full node REST API 端口；
* 9101：full node 指标端口；
  {% endhint %}

### 申请激励测试网（Apply for Incentivized Testnet）

网站（Website）：<https://community.aptoslabs.com/>

```bash
sudo cat ~/aptos-node/testnet3/keys/public-keys.yaml
```

* OWNER KEY: 安装钱包插件后，钱包的公钥，Settings -> Credentials
* CONSENSUS KEY:  `public-keys.yaml` 文件中的 consensus\_public\_key
* CONSENSUS POP: `public-keys.yaml` 文件中的 consensus\_proof\_of\_possession
* ACCOUNT KEY: `public-keys.yaml` 文件中的 account\_public\_key
* VALIDATOR NETWORK KEY: `public-keys.yaml` 文件中的 validator\_network\_public\_key

### 全节点搭建（可选）

请参考下一篇

对教程有建议？欢迎加入 MoveMove 社区：<https://discord.gg/Vsj7Jwny9G>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.aptos.movemove.org/jiao-cheng/ce-shi-wang-testnet/she-qu-jiao-cheng/shi-yong-docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
