4

Every time I upgrade parity on docker by pulling and creating a new container I lose all sync data.

The Dockerfile doesn't seem to expose a volume I could mount with -v

Is there a trick to it or should I ignore it now that Parity can auto-update (since 1.5)?

1 Answer 1

2

The solution is to mount it on docker with -v to a local folder

Example

First on your host create the folder where parity is going to save the data

mkdir /srv/parity

Then make sure you have the latest version of parity

docker pull parity/parity:nightly

And finally create the container with the following parameters:

  • -v /srv/parity:/root/.local/share/io.parity.ethereum/ (mount your local folder /srv/parity to the containers parity storage

Full run command:

docker run -ti -d -p 8545:8545 --name parity -v /srv/parity:/root/.local/share/io.parity.ethereum/ parity/parity:nightly --jsonrpc-interface '0.0.0.0' --jsonrpc-hosts="all" --author "0xYOURETHADDRESS" --auto-update="all" -d /mnt

Note: This command will also:

  • Allow the JSON RPC interface to be accessed by anyone in your network so don't use this command on an exposed server
  • Enable the auto-update of Parity which was introduced in 1.5
  • Allows you to solo-mine by specifying the "author" parameter

After you ran the command you can verify that everything worked by checking the /srv/parity folder on your docker host

Checking parity folder


Bonus dev script:

You can use the following bash script to update parity whenever you like. It removes the old container, creates a new but keeps the data

#!/bin/sh

docker pull parity/parity:nightly
docker rm -f parity
docker run --restart always -ti -d \
-p 8180:8180 -p 8545:8545 -p 8546:8546 -p 30303:30303 -p 30303:30303/udp \
--name parity --restart always \
-v /srv/parity:/root/.local/share/io.parity.ethereum/ parity/parity:nightly \
--jsonrpc-interface '0.0.0.0' --jsonrpc-hosts="all" \
--author 0xYOURETHADDRESSHERE \
--auto-update="all" \
--stratum --stratum-interface=0.0.0.0 \
--jsonrpc-cors null \
--unsafe-expose \
--db-compaction hdd \
--mode active --cache-size 4096 \
--ui-interface 0.0.0.0 --ui-no-validation

docker logs --follow parity
2
  • Actually the -d means detached mode. Did your solution work? Mar 22, 2018 at 10:25
  • 1
    Parity changed a lot since I wrote this answer so I just updated it to work with current versions. The use of "-d" is discuraged now because it renders parity unable to perform key generations
    – Christian
    Mar 22, 2018 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.