Run script on host before first container start


I want to run a script before the start of the first container. The host is archlinux and LXD is using snap. Do i need to write a systemd init script or is there a place i can drop in a script.

The script which i need to run is to initialize the GPU with the following contents,

nvidia-container-cli --user=1001:1002 -k -d /dev/tty list


I added the command to snapd.service,

#systemctl edit snapd.service
ExecStartPre=/usr/bin/nvidia-container-cli --user=1001:1002 -k -d /dev/tty list

So the command is run before snapd/lxd starts.

oh thank you @trumee :slight_smile:

I was trying and failing for quite some time to do something and I had missed this possibility.

It’s possible to do the same with lxd service (systemctl edit snap.lxd.daemon)