How To Deploy A Chainlink Node with Docker
In this comprehensive guide, we will walk you through the process of deploying a Chainlink node, from setting up the hardware and software requirements to connecting to the network.
What is a Chainlink Node?
A Chainlink node is a decentralized oracle network that provides secure and reliable access to real-world data for smart contracts. Chainlink nodes are run by independent node operators who use their hardware and software to connect to external data sources, such as APIs, and deliver that data to smart contracts on the blockchain.
Chainlink nodes foster the development of decentralized applications (dApps) that require access to real-world data. As the DeFi ecosystem continues to grow, Chainlink nodes will become increasingly important for providing secure and reliable access to real-world data.
When running a Chainlink node, you can:
- Earn LINK tokens by providing data to smart contracts.
- Help to secure the Chainlink Network and make it more decentralized.
- Contribute to the development of decentralized applications.
Here are some additional resources that you may find helpful:
- Chainlink Website: https://chain.link/
- Chainlink Documentation: https://docs.chain.link/
- Chainlink Blog: https://blog.chain.link/
- Chainlink Twitter: https://twitter.com/chainlink
Chainlink Node Requirements
Hardware Requirements:
- The hardware requirements for running a Chainlink node depend on the workload it handles, particularly the number of jobs it services.
- For optimal performance in production environments, it is advisable to use CPUs with the x86 architecture.
- During development, you can use Apple M1 ARM systems to run the Chainlink node in Docker.
Minimum Requirements:
- To set up a node for testing and basic development, your system should have at least 2 CPU cores and 4 GB of RAM.
Recommended Requirements:
- For nodes intended for production environments with more than 100 jobs, it is recommended to have at least 4 CPU cores and 8 GB of RAM.
Additional Hardware for Local PostgreSQL Database:
- If you run your PostgreSQL database locally to support more than 100 jobs, your database server will require a minimum of 4 cores, 16 GB of RAM, and 100 GB of storage.
Cloud Platform Considerations:
- When using AWS or another cloud platform, opt for a VM instance type with dedicated core time for improved performance.
- Instances with burstable performance or shared cores might not deliver consistent performance for Chainlink nodes and are, therefore, not recommended.
Software Requirements:
Operating System:
- Linux, MacOS, or the Windows Subsystem for Linux (WSL). Linux is the preferred choice for production environments. Docker:
- While it is possible to build Chainlink nodes from source, the best practice is to use the Chainlink Docker Images without -root option. PostgreSQL:
- Versions >=11 and <16 (Version 11 through 15, excluding version 16 or later).
- When using a database as a service, ensure that your database host provides access to logs.
- For databases running on a separate system, secure the TCP/IP connection with SSL.
Blockchain Connectivity:
- Chainlink nodes require a fully-synced network client to execute on-chain transactions and interact with deployed contracts.
- For Ethereum, refer to the list of supported clients.
- Different L1s, L2s, and side-chains use distinct clients, so consult your network's documentation for instructions on running a client for your specific network.
Client Requirements:
- While you can use a provider like Alchemy or Infura, running your own client offers advantages such as lower latency and greater decentralization.
- For optimum performance, run your Chainlink nodes on separate VMs or systems. As the hardware and storage requirements for these clients may change over time, scaling their capacity separately from the system where you run your Chainlink nodes might be necessary.
- Ensure that the client provides both HTTP and WebSocket connections secured with SSL. Most providers offer default
https://
andwss://
connections. If running your own client, set up a reverse proxy using a web server like Nginx to handle SSL encryption and forward the connection to your client.
You can get updated requirements on Chainlink Docs.
How to Deploy a Chainlink Node with Docker
Please note that while running the Chainlink node from the source is an option, this guide focuses on the preferred method of using Docker, as it streamlines the setup process and ensures smooth integration with the Chainlink ecosystem.
Step 1: Supported Networks
Before you start, ensure your node is configured to provide data to the desired blockchain network, such as Ethereum Sepolia or Goerli testnet.
Step 2: Install Docker Desktop
To proceed with setting up the Chainlink node, you'll need Docker Desktop installed on your system. Docker will allow you to encapsulate the node's environment and dependencies, making it easy to manage and deploy across different systems.
Step 3: Run PostgreSQL in Docker
PostgreSQL is a prerequisite for the Chainlink node. Follow the commands below to run PostgreSQL in a Docker container:
docker run --name cl-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
Step 4: Configure Your Chainlink Node
Create a local directory to store the Chainlink data:
mkdir ~/.chainlink-sepolia
Next, create a config.toml
file with network-specific variables. Replace CHANGEME
with the appropriate values for your external Ethereum provider:
echo "[Log]
Level = 'warn'
[WebServer]
AllowOrigins = '\*'
SecureCookies = false
[WebServer.TLS]
HTTPSPort = 0
[[EVM]]
ChainID = '11155111'
[[EVM.Nodes]]
Name = 'Sepolia'
WSURL = 'wss://CHANGE_ME'
HTTPURL = 'https://CHANGE_ME'
" > ~/.chainlink-sepolia/config.toml
Create a secrets.toml
file containing a keystore password and your database URL:
echo "[Password]
Keystore = 'mysecretkeystorepassword'
[Database]
URL = 'postgresql://postgres:[email protected]:5432/postgres?sslmode=disable'
" > ~/.chainlink-sepolia/secrets.toml
Optional: Create an.api
file with API and Operator UI credentials:
echo "CHANGE_THIS_EXAMPLE_EMAIL CHANGE_THIS_EXAMPLE_PASSWORD " > ~/.chainlink-sepolia/.api
Step 5: Start the Chainlink Node
Launch the Chainlink node Docker image:
cd ~/.chainlink-sepolia && docker run --platform linux/x86_64/v8 --name chainlink -v ~/.chainlink-sepolia:/chainlink -it -p 6688:6688 --add-host=host.docker.internal:host-gateway smartcontract/chainlink:2.3.0 node -config /chainlink/config.toml -secrets /chainlink/secrets.toml start
Step 6: Access the Chainlink Node UI
You can now access your Chainlink node's UI interface by visiting http://localhost:6688 in your web browser. Use the API credentials you set up earlier to log in.
Step 7: Configure Users and Roles
For added security, set up role-based access tiers by creating multiple users with different privileges. The Chainlink CLI is used for this purpose:
docker exec -it chainlink /bin/bash
chainlink admin login
: to log into Chainlink CLI.
chainlink admin users create [email protected] --role=view
: to add users.
chainlink admin users list
: to confirm the list of current users.
chainlink admin logout
: to log out of Chainlink CLI.
exit
: to exit the container.
Congratulations! You've successfully deployed your own Chainlink node using Docker. As you continue your journey into this world, you can explore various features and possibilities offered by Chainlink, such as fulfilling requests, role-based access control, system maintenance, and best practices for security and operation. Get more information on Chainlink's official channels.