Execute SH script on container start

In LXD 3.0, how can I have a .sh script that’s inside the container run automatically on lxc start containername? I tried adding it to systemd but it doesn’t run.

I am running Ubuntu 18.04 under a LXD 3.0 container

Systemd is the right answer, if it’s not starting, it’s probably because of the target it’s tied to or another issue with the way the unit was setup.

I think I will have to go through the process again. It runs when executed manually just not by systemd.

Did you make sure it has an install section and that you ran systemctl enable UNIT?