Running bash Commands at Container Startup

I wanted to run bash commands at container startup to start a binary in the container but the container wont start now,

ubuntu@ubuntuvm:~$ sudo incus config set rumqttd user.meta-data - < ./startup.sh
ubuntu@ubuntuvm:~$ sudo incus start rumqttd
Error: Failed to run: /opt/incus/bin/incusd forkstart rumqttd /var/lib/incus/containers /var/log/incus/rumqttd/lxc.conf: exit status 1
Try `incus info --show-log rumqttd` for more info
ubuntu@ubuntuvm:~$ sudo incus info --show-log rumqttd
Name: rumqttd
Status: STOPPED
Type: container
Architecture: x86_64
Created: 2023/11/24 19:13 EAT
Last Used: 2023/11/24 22:17 EAT

Log:

lxc rumqttd 20231124191722.744 ERROR    conf - ../src/lxc/conf.c:lxc_map_ids:3701 - newuidmap failed to write mapping "newuidmap: uid range [0-1000000000) -> [1000000-1001000000) not allowed": newuidmap 20564 0 1000000 1000000000
lxc rumqttd 20231124191722.744 ERROR    start - ../src/lxc/start.c:lxc_spawn:1788 - Failed to set up id mapping.
lxc rumqttd 20231124191722.745 ERROR    lxccontainer - ../src/lxc/lxccontainer.c:wait_on_daemonized_start:878 - Received container state "ABORTING" instead of "RUNNING"
lxc rumqttd 20231124191722.754 ERROR    start - ../src/lxc/start.c:__lxc_start:2107 - Failed to spawn container "rumqttd"
lxc rumqttd 20231124191722.754 WARN     start - ../src/lxc/start.c:lxc_abort:1036 - No such process - Failed to send SIGKILL via pidfd 17 for process 20564
lxc 20231124191722.838 ERROR    af_unix - ../src/lxc/af_unix.c:lxc_abstract_unix_recv_fds_iov:218 - Connection reset by peer - Failed to receive response
lxc 20231124191722.838 ERROR    commands - ../src/lxc/commands.c:lxc_cmd_rsp_recv_fds:128 - Failed to receive file descriptors for command "get_init_pid"


lxc rumqttd 20231124191722.744 ERROR    conf - ../src/lxc/conf.c:lxc_map_ids:3701 - newuidmap failed to write mapping "newuidmap: uid range [0-1000000000) -> [1000000-1001000000) not allowed": newuidmap 20564 0 1000000 1000000000

This indicates that your system is using /etc/subuid and /etc/subgid to mediate UID/GID ranges. You’ll need to either update those two files to allow Incus to operate with the uid/gid ranges that you want (adding those allocatiosn to the root user) and then restart incus, or if on a Debian/Ubuntu system, you may instead just uninstall the uidmap package, remove /etc/subuid, remove /etc/subgid and finally restart Incus to have it run with no such contraints.