# Using Docker

## Deploy a PFN using Docker

This section describes how to configure and run your PFN using Docker.

{% hint style="info" %}
Supported only on x86-64 CPUs Running endless-core via Docker is currently only supported on x86-64 CPUs.
{% endhint %}

Ensure Docker Cli and service are available. If not, install [Docker](https://docs.docker.com/get-docker/)

Next, the user chooses whether to run the Docker container with the default configuration or a customized configuration.

### Default configuration

The default configurations:

* `endless-node` program is located at `/usr/local/bin/`
* The working directory is located under `/opt/endless/`
  * The data directory stores synchronization `/opt/endless/data`
  * The genesis and waypoint files are located in the `/opt/endless/genesis` directory
  * The P2P synchronization port is set to `0.0.0.0:6182`
  * The GRPC stream service is disabled by default.

### Customized Configuration

If the user wishes to run with a customized configuration, the following steps are required:

We presume user construct the following directory: base\_dir, eg. /opt/endless/

```
base_dir/
        |- fullnode.yaml
        |- data/
        |- mainnet/
                  |- genesis.blob, waypoint.txt 
```

1. User select run the following script to prepare your local configuration and data directory for mainnet. This will download the `fullnode.yaml` configuration file, the `genesis.blob` and `waypoint.txt` files for your PFN, and create a `data` directory to store the blockchain database:

```bash
mkdir -p /opt/endless/mainnet && mkdir -p /opt/endless/data
cd /opt/endless/mainnet && \
curl -o /opt/endless/mainnet/waypoint.txt https://raw.githubusercontent.com/endless-labs/endless-release/main/endless-networks/mainnet/genesis_waypoint.txt && \
curl -o /opt/endless/mainnet/genesis.blob https://raw.githubusercontent.com/endless-labs/endless-release/main/endless-networks/mainnet/genesis.blob
```

{% hint style="info" %}
Don't want to connect to mainnet? To connect to other networks (e.g., `testnet`), you can find the genesis and waypoint here ➜ <https://github.com/endless-labs/endless-networks>. Be sure to download the `genesis.blob` and `waypoint.txt` for those networks, instead of using the genesis and waypoint pointed to by the `curl` commands above.
{% endhint %}

2. Create `fullnode.yaml` configuration file, please refer [Sample Configuration of PFN](https://docs.endless.link/endless/devbuild/nodes/run-a-public-fullnode/using-precompiled-binary#sample-configuration-of-pfn):

Your `fullnode.yaml` should look like the following:

```yaml
base:
  role: "full_node"
  data_dir: "/opt/endless/data"
  waypoint:
    from_file: "/opt/endless/mainnet/waypoint.txt"

execution:
  genesis_file_location: "/opt/endless/mainnet/genesis.blob"

full_node_networks:
   - network_id: public
      seed_addrs:
         0x415ef8d74118495935e60961806f24a8b502072378c73bdd87661d41a486ce1b:
         - /dns/chain-r-1.endless.link/tcp/6182/noise-ik/0x415ef8d74118495935e60961806f24a8b502072378c73bdd87661d41a486ce1b/handshake/0
         0xd8025b203853e3253393c80d8e81184983a4a00dfc23b432112e72ce1f827d69:
         - /dns/chain-r-2.endless.link/tcp/6182/noise-ik/0xd8025b203853e3253393c80d8e81184983a4a00dfc23b432112e72ce1f827d69/handshake/0
         0x52d09187b0bcc2e24f5aea940910ac42a645c231e6c0c9eebc65676350f1e94e:
         - /dns/chain-r-3.endless.link/tcp/6182/noise-ik/0x52d09187b0bcc2e24f5aea940910ac42a645c231e6c0c9eebc65676350f1e94e/handshake/0
         0x40cc7d84ecaf0b4afd364d7d5bb260aa71f31812c4c8f46be6fd68cccaba1d49:
         - /dns/chain-r-4.endless.link/tcp/6182/noise-ik/0x40cc7d84ecaf0b4afd364d7d5bb260aa71f31812c4c8f46be6fd68cccaba1d49/handshake/0
         0x2f9aac167b64843718a362bb2e4188b031ffcec500e80fd17582cde9437ffb07:
         - /dns/chain-r-5.endless.link/tcp/6182/noise-ik/0x2f9aac167b64843718a362bb2e4188b031ffcec500e80fd17582cde9437ffb07/handshake/0
      listen_address: /ip4/0.0.0.0/tcp/6182

api:
  enabled: true
  address: "0.0.0.0:8080"
```

3. Run the following `docker` command:

```bash
docker run --pull=always \
    --rm -p 8080:8080 \
    -p 9101:9101 -p 6180:6180 \
    -v $(pwd):/opt/endless \
    -v $(pwd)/data:/opt/endless/data \
    --workdir /opt/endless \
    --name=endless-fullnode endlesslab/endless-node:latest
```

You have now successfully configured and started running a PFN in the Endless mainnet.
