# Docker

This guide will walk you through setting up `hostd` using Docker compose. At the end of this guide, you should have the following:

* Installed Sia `hostd` software
* Created a `hostd` wallet

***

## Pre-requisites

To ensure you will not run into any issues with running `hostd` it is recommended your system meets the following requirements:

* **Hardware Requirements:** A stable setup that meets the following specifications is recommended. Not meeting these requirements may result in fewer contracts from renters or the loss of collateral.
  * A quad-core CPU
  * 8GB of RAM
  * 256 GB SSD for `hostd`
    * 10 GB per 1 TB hosted for database storage
  * At least 4TB of HDD storage for renter data
* **Network Access:** `hostd` requires a stable internet connection and open network access to store and retrieve data on the Sia network.
* **Software Requirements:** Before installing `hostd`, you will need to install [Docker](https://www.docker.com/get-started/).

## Create the compose file

Create a new file named `docker-compose.yml`. You can use the following as a template. The `/data` mount is where consensus data is stored and is required. Change the `/storage` mount to the path of your storage drive. If you have additional storage disks, add them.

```yml
services:
  hostd:
    image: ghcr.io/siafoundation/hostd:latest
    restart: unless-stopped
    ports:
      - 127.0.0.1:9980:9980/tcp
      - 9981-9984:9981-9984/tcp
    volumes:
      - hostd-data:/data
      - /storage:/storage

volumes:
  hostd-data:
```

{% hint style="warning" %}
Be careful with port 9980 as Docker will expose it publicly by default. It is recommended to bind it to 127.0.0.1 to prevent unauthorized access. If you need to expose it to a LAN, ensure the port is not accessible publicly.
{% endhint %}

## Getting the `hostd` image

To get the latest `hostd` image run the following command:

```
docker compose pull
```

## Configuring `hostd`

Now that you have the latest `hostd` image downloaded, you will need to create a seed phrase and admin password. To launch the built-in configuration wizard, run the following:

```console
docker compose run --rm -it hostd config
```

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-08f32b9a163c311e475ce979050d59741a17c133%2Fdocker_hostd_config.gif?alt=media)

When the configuration wizard loads, you will be asked to verify the location of your data directory. Type `no` to keep the default.

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-e04c332a98b0b354a962bd5911879195b57dce7c%2F01_docker_hostd_config.png?alt=media)

Next, you will be asked to enter a seed phrase. If you already have one that you would like to use, you can enter it now. Otherwise, you can type `seed` to generate a new one. For the purpose of this guide, we will generate a new seed.

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-589ad8b2dd7db3145c70d82b35629d09efea2f91%2F02_docker_hostd_config.png?alt=media)

Next, you will be prompted to enter an admin password. This is used to unlock the `hostd` web UI.

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-ba22b0b219d8e2f03bc6ec3b3aab9e6114fd3ca4%2F03_docker_hostd_config.png?alt=media)

Finally, you will be asked if you want to configure advanced settings for `hostd`. Type `no` and hit enter to exit the configuration wizard.

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-da0c516901ddadf99a519bccd6d652fe864ca8b8%2F04_docker_hostd_config.png?alt=media)

## Running `hostd`

Now that you have `hostd` successfully installed and configured, it is time to run it. Use the following command to start `hostd`:

```console
docker compose up -d
```

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-245e39e67fdda06e7f4dc8873f95b492714f164c%2F06-hostd-startup.png?alt=media)

Once `hostd` has successfully started, you can access the web UI by opening your browser and going to [http://localhost:9980](http://localhost:9980/).

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-9109bcdf8a629a69696592e04843a0b8ab338d0b%2F07-hostd-webui.png?alt=media)

{% hint style="success" %}
Congratulations, you have successfully set up `hostd`.
{% endhint %}

## Checking the container status

To check the status of the container run:

```
docker ps -a
```

If the container is not running, it will show in the `STATUS` column

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-977bff9d7c01ac7a395c57f95116fa2d2c903627%2F07_docker_hostd_status.png?alt=media)

## Checking the logs

To check the container logs run:

```
docker compose logs hostd
```

![](https://3679771871-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6w9fYqdazlo30V4aFg36%2Fuploads%2Fgit-blob-55fc369f5d0910dca87663ab2df4f1868ebdfda2%2F08_docker_hostd_logs.png?alt=media)

## Upgrading `hostd`

It is essential to keep your host up to date. New versions of `hostd` are released regularly and contain bug fixes and performance improvements.

To upgrade your `hostd` to the newest version, make sure you have shut down `hostd` and then run the following:

```console
docker compose pull && docker compose up -d
```

{% hint style="success" %}
Congratulations, you have successfully updated your version of `hostd`!
{% endhint %}
