# Run with docker

Please ensure that [Docker ](https://docs.exsat.network/others/operation-references/preparation-before-you-start/prerequisites#running-with-docker)is installed on your Linux server.

## 1. Download docker image

```
docker pull exsatnetwork/exsat-client:latest
```

## 2. Download and configure the environment variables (.env)

Please create a directory (e.g., `$HOME/.exsat/`) to store the files for running the exSat Client via Docker. We will download the `.env` file directly from GitHub into this directory, and edit it.

```
mkdir -p $HOME/.exsat/
curl -o $HOME/.exsat/.env https://raw.githubusercontent.com/exsat-network/exsat-client/main/.env.example
vim $HOME/.exsat/.env
```

Please ensure all configurations are correctly set. Some settings can also be adjusted in the next steps. Detailed configurations can be found [here](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/environment-variables).

## 3. Initialize the account and configure the Client

Start Docker in interactive mode：

```
docker run -it --name commander -v $HOME/.exsat/:/app/.exsat -e CLIENT_TYPE=commander exsatnetwork/exsat-client:latest
```

Perform below actions in the docker.

### 3.1 Initiate the validator account

#### Create or import the account

If you don't have a validator account, please [create a new account](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/validator-operations/create-new-btc-validator-account).

If you already have a validator account, and wish to import it to your client, please [import seed phase](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/import-from-seed-phrase) or [import private key](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/import-from-private-key).

#### Stake for your validator account

To qualify as a BTC Validator, you must stake a minimum of 100 BTC. This can be done through either [Credit Staking](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/validator-operations/stake-for-validator-via-credit-staking) or [XBTC Staking](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/validator-operations/stake-for-validator-via-xbtc-staking-or-xsat-staking). Learn more about the two staking methods [here](https://docs.exsat.network/guides-of-data-consensus/run-a-btc-validator/credit-staking-and-xbtc-staking).

### 3.2 Configurations

You can complete some client configurations or perform operations on your account:

* [Set BTC RPC Node](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/set-btc-rpc-node) (**required**, can also be done by editing the .env file)
* [Bridge BTC for gas fee](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/refill-btc-for-gas-fees) (**required**)
* [Change Stake Address](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/validator-operations/change-stake-address) (optional)
* [Change Reward Address](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/synchronizer-operations/change-reward-address)(optional)
* [Change Commission Ratio](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/validator-operations/change-commission-ratio)(optional)
* [Configure Display Information](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/validator-operations/configure-display-information-for-your-validator-account) (optional)
* [Export private key](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/export-private-key) (optional)
* [Remove your account](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/remove-your-account) (optional)
* [New version check](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/upgrade-to-new-version) (optional)

## 4. Execute the Client

Please ensure that you have [configured the BTC RPC Node](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/set-btc-rpc-node), [bridged gas fee for your validator account](https://docs.exsat.network/guides-of-data-consensus/others/operation-references/common-operations/refill-btc-for-gas-fees).

There are several ways to start the client using Docker, differing in how the keystore password is provided. Choose the method you prefer.

Assuming the keystore file is stored at `$HOME/.exsat/goodvali_keystore.json`and the password is `123456` , the keystore file path in ".env" file should be look like:

```
VALIDATOR_KEYSTORE_FILE=/app/.exsat/goodvali_keystore.json
```

### Option 1 : Password stored in ".env"

&#x20;Please configure password in the `.env` file:

```
VALIDATOR_KEYSTORE_PASSWORD=123456
```

Then, start the Docker container with the following command:

```
docker run -d --restart always --name goodvali -v $HOME/.exsat/:/app/.exsat -e CLIENT_TYPE=validator exsatnetwork/exsat-client:latest
```

### Option 2 : Input password in the command

Start docker container with the password as parameter in the command:

```
docker run -d --restart always --name goodvali -v $HOME/.exsat/:/app/.exsat -e CLIENT_TYPE=validator -e VALIDATOR_KEYSTORE_PASSWORD=123456 exsatnetwork/exsat-client:latest
```

### Option 3 : Interactive Password Input

Start Docker in interactive mode and enter the password in the command line interface.

```
docker run -it --name goodvali -v $HOME/.exsat:/app/.exsat -e CLIENT_TYPE=validator exsatnetwork/exsat-client:latest
```

> Different startup methods vary in terms of security and convenience. If you start the client interactively and enter the password in the interface, the password won't be stored in plain text in the startup command or files, reducing the risk of exposure. However, if you provide the password in the `.env` file or directly in the command line, it may be more prone to leakage but offers greater convenience during startup.

If your Validator Client is running correctly, the following logs should appear on your screen:

```
2025-02-28T12:25:23.325+00:00 info: ExsatApi initialized successfully.
2025-02-28T12:25:24.051+00:00 info: Validator[btcval.sat] client configurations are correct, and the startup was successful
2025-02-28T12:25:25.499+00:00 info: Endorse task is running
2025-02-28T12:25:26.158+00:00 info: Endorse task is finished
```

Check [this guide](https://docs.exsat.network/others/operation-references/common-operations/view-logs#running-with-docker) for detailed instructions on viewing the logs.

## 5. Check and claim rewards

You could [check and claim rewards](https://docs.exsat.network/others/operation-references/validator-operations/stake-for-validator-via-xbtc-staking-or-xsat-staking#claim-rewards) on the front-page with the reward address.

## 6. Update to new Docker image

When exSat releases a new Docker version, you can upgrade to the latest version by running the following commands (assuming you have been following the previous steps).

```
docker pull exsatnetwork/exsat-client:latest
docker stop goodvali
docker rm goodvali
docker run -d --restart always --name goodvali -v $HOME/.exsat/:/app/.exsat -e CLIENT_TYPE=validator exsatnetwork/exsat-client:latest
```
