Running a Parity Docker Container with Custom Configuration
Running the Parity Ethereum Client as a Docker container with a custom configuration is a relatively simple task, that usually only…
Running the Parity Ethereum Client as a Docker container with a custom configuration is a relatively simple task, that usually only requires mounting one or two files (depending whether a custom chain is also configured or not) to the container.
TL;DR
A GitHub repository with the complete example is available here:
GitHub - ItayPodhajcer/parity-docker-custom-configuration
Contribute to ItayPodhajcer/parity-docker-custom-configuration development by creating an account on GitHub.
To start, we’ll create two directories:
src: will contain the configuration fileseng: will contain the docker compose file
Generate Wallet
To generate a wallet, use whatever client you feel comfortable with, such as MyCrypto which has both an online and a desktop version.
You can also use something like Secure Password Generator to easily generate a password that meets the required complexity policy.
Chain Genesis File
Create a chain.json file inside the src directory. We won’t be using one of the predefined configurations (taken from here):
mainnet(default) main Ethereum networkkovanortestnetthe fast Ethereum test networkropstenthe old Ethereum test networkclassicEthereum Classic networkclassic-testnetoriginal Morden testnet and current Ethereum Classic testnetexpanseExpanse networkdeva Private development chain to be used locally, submitted transactions are inserted into blocks instantly without the need to minemusicoinMusicoin networkellaismEllaism networktobalabaEWF Tobalaba network
Instead, we’ll use the dev chain file found here and copy it’s content to our file, so we can customize it with the wallet address we generated.
Look for the accounts section and add an entry at the end with the address of the generated wallet:
"8e337cf273111ccfa7c33cca3a0600ee5706e68c": { "balance": "1000000000000000000000000000" }Configuration File
Next we create a config.toml file, also inside the src directory. Our configuration file will be very simple, just the base directory and the path to the chain.json file:
[parity]# Custom chainchain = "/home/parity/.local/share/io.parity.ethereum/chain.json"# Blockchain and settings will be stored in ./.base_path = "./"For more complex configurations, considering using the Parity Config Generator, as it greatly simplifies the process of creating the configuration file by providing an explanation on the available options and possible values where relevant.
Docker Compose File
Our docker compose file (docker-compose.yml), which will be created in the eng directory, will have only one service defined for the purpose of this example, but can be extended with whichever container you may require. The service will be a Parity container (obviously) with the two configuration files mounted to the /home/parity/.local/share/io.parity.ethereum directory with the ports 8545, 8546, 30303 and 30303/udp exposed. The end result should look like this:
version: '3.7'services: parity: container_name: custom-parity image: parity/parity volumes: - ../src/chain.json:/home/parity/.local/share/io.parity.ethereum/chain.json - ../src/config.toml:/home/parity/.local/share/io.parity.ethereum/config.toml command: --config /home/parity/.local/share/io.parity.ethereum/config.toml restart: always ports: - 8545:8545 - 8546:8546 - 30303:30303 - 30303:30303/udpRunning The Container
Now the only thing left to do to run the container is execute docker-compose up from the directory containing the YAML file, or docker-compose -f <path to YAML file> up from any other path.