Running script on container statup (Alpine Linux)

I think the issue (why Alpine wiki didn’t help) is that many of the usual startup hooks don’t fire in a container, since it doesn’t “boot” in the usual sense. That apparently includes the /etc/network/if-*.d/ directories, which might get processed if you created interfaces via /etc/network/interfaces, but not if LXD does the job from outside.

As a workaround, I enabled the local service:

alpine$: rc-update add local default

I then created a shell script /etc/local.d/some-script.start (hence the local service):

#!/bin/ash

ip (…) dev eth0   # modify veth endpoint created by LXD

Finally, chmod 755 some-script.start and you’re good to go.

Setting a static ip address this way works too; lxc ls will display it correctly. Haven’t tested thoroughly yet, but traffic over the bridge appears to be routed normally.