Configuring low level LXC options via API

Jun 3, 2026
3
0
1
I want to create an LXC container on my PVE node and I need to set some low level options (like lxc.environment and lxc.hook.pre-start). It works fine if I SSH onto the node and edit the file /etc/pve/lxc/4711.conf manually .
But since I need to integrate this into an automated workflow, I would like to know if there is some way to do this via the API.
 
you can set the environment with the `env` parameter and a PVE hookscript with the `hookscript` one (both are root only IIRC). arbitrary low level options are intentionally not exposed on the API.
 
  • Like
Reactions: Johannes S
I also need lxc.hook.mount. Is this one somehow exposed?
Not via the API. The available phases in a hookscript are pre-start, post-start, pre-stop, and post-stop.

Does the env parameter really work for this? The documentation I found states that it sets the lxc.environment.runtime option and not lxc.environment
Depends on what your goal is. The env parameter sets the environment variables inside the container. They do not apply to hook scripts.
 
  • Like
Reactions: Johannes S
OK, that means if I want to be able to automatically (without SSHing onto the node) create containers with the stated options configured, my only option is to prepare a template and clone that one, correct?
 
If you really have to create a container with lxc.* parameters via the API and your use case cannot be solved via the exposed parameters, then yes, cloning a prepared template is the only option I can think of.