How to customize Docker startup parameters in Synology NAS?

You probably found that it is not that easy to overwrite the default Docker container command if you are running it in your Synology NAS.

Maybe you came across the following error:

“Unable to perform this operation, possibly the network connection is unstable or the system is busy. Please try again later.”

Actually, this error message is completely misleading, as this error during Docker container startup has nothing to do with your network nor with the system being busy.

The reason this error message is shown is that the Synology NAS is unable to start the container because of an error within the containers startup parameter.

Most likely this happened because you tried to customize the startup parameter of your Docker container through the Synology NAS GUI, as it is shown below:

In order to fix this and to correctly customize your containers startup parameters follow the next steps:

  • Start the container with all your GUI defined settings and with the default startup container command.
  • Go to the list of running Docker containers within your Synology NAS and export the containers configuration as JSON. You only need to export the lightweight JSON config, NOT the entire container data!
  • Open the exported JSON with a text editor, add your startup parameter as shown below (don’t forget to escape the ‘=’ character as shown below).
  • Stop and delete your running container.
  • Import the exported config and start the modified Docker container.

See below the part of the Synology NAS exported Docker container config that contains the startup cmd:

{
  "CapAdd" : null,
  "CapDrop" : null,
  "cmd" : "--customparam\\=customvalue --storage.tsdb.retention.time\\=5y --config.file\\=/opt/bitnami/prometheus/conf/prometheus.yml --storage.tsdb.path\\=/opt/bitnami/prometheus/data --web.console.libraries\\=/opt/bitnami/prometheus/conf/console_libraries --web.console.templates\\=/opt/bitnami/prometheus/conf/consoles",
  "cpu_priority" : 0,
  "enable_publish_all_ports" : false,
  "enable_restart_policy" : true,

Conclusion

It seems that Synology NAS introduced some GUI issues when composing the overwritten Docker container execution command. My guess is that it’s confusing the escaping of the equals character when taking the value from the GUI text field.

You can easily overcome that issue by exporting, modifying and importing the Docker configuration as a JSON file.