Modifying services.json in local docker cluster

Im currently setting up a local docker cluster and am running into some problems with the configuration of each node. For the container setup I’ve followed this docker-compose.yml and it works well in default config. However, I want to use the replication_factor (max and min) settings and also set leave_on_shutdown = true on each node and am unsure about how to do this properly.

Currently I start then cluster nodes with a shell script , stop them, edit the service.json file and restart the containers. It’s a bad approach and doesn’t really work, because I have to use loads of sleep in my shell script to prevent raft from throwing errors. Also, I cant restart all cluster containers at the same time, as raft looses its leader and is unable to elect a new one (not sure why exactly)

So I’m wondering how to initialise the ipfs-cluster-service and override the config defaults or change the settings while the container is running. Would be great to get some insight on how to do this.

Hi! You can override the service.json configuration values using environment variables (for the main section and the restapi section only though):


Must have missed that in the docs! For some reason this doesn’t work though. This is included in my docker-compose:

  CLUSTER_SECRET: xxxxxxxxxxxxxxx.... 

When I inspect the environment variables in the container, they’re set properly but the values for replication_factor and leave_on_shutdown dont show in the service.json (while the secret does, works as expected). Is there anything else I’m missing?

Right, so they don’t overwite the service.json values in the file, but they do take effect in the cluster-service when it’s launched. So when you pin an item it should use the environment values for replication factor instead of the ones in service.json.

I see. Somewhat confusing that the secret is updated in service.json, but the other values aren’t. I created an issue in the website repo, maybe someone can add a warning or something like that. Thanks a lot for your help!

Ah right, the cluster secret is used during init but the other variables only override an existing config. Maybe we should change this and have them used on init too.

1 Like