Configuration in snaps


Certain snaps, such as those providing a background service, expose configuration options that can be examined and altered.

The commands for viewing and changing these configuration options are snap get and snap set.

For example, to see the configuration options exposed by an installed snap, enter snap get <snap name>:

$ sudo snap get nextcloud
Key        Value
nextcloud  {...}
php        {...}
ports      {...}
private    {...}

The {...} in the above output indicates further options beneath the current key name level.

To explore configuration options, append the key name to the get command:

$ sudo snap get nextcloud ports
Key          Value
ports.http   80
ports.https  443

Use the set command to change a configuration option:

$ sudo snap set nextcloud ports.http=81

The update process will test the validity of the configuration options. If any errors are detected, the overall change is cancelled and the previous configuration reinstated.

Similarly, if the configuration update process takes longer than a reasonable amount of time, currently 5 minutes, the update is forcefully aborted and the once again the configuration is rolled back.

Getting started
Change device initialization options externally
Snap Documentation
System options
JMESPath in the snap tooling, we need your help
Hook timeout mechanism not working in 2.24

(perhaps this is not the right place to ask, if so, my apologies and feel free to move my reply, but the example in this post matches exactly what I’m trying to adjust)

I’m trying to limit nextcloud (i.e.apache) to localhost, and according to the docs, I should be able to specify it as follows:

sudo snap set nextcloud ports.http=

But I get: - Run configure hook of "nextcloud" snap (run hook "configure": "" is not a valid HTTP port). Is the nextcloud snap’s check too strict, or am I doing something wrong?



Are there any limits in the length of config values?


Maybe 80 is an accepted value?


I seem to remember someone saying that the max length of a value with snap set THE_SNAP key=val is 32K