Docker custom image - start snmp service on boot

The issue I am facing:
I use the pihole docker image on kubernetes and as part of this i do a simple rebuild/republish of the image in order to perform some customisations, one of which is installing and configuring snmp. this works fine, however the challenge I have is that i cannot get the snmp service to start automatically on boot. If using /etc/init.d/snmpd i can start the service manually and it runs fine, i just need some guidance on how i can make this happen automatically on boot please
Details about my system:
pihole docker image
What I have changed since installing Pi-hole:

curl -o /usr/bin/distro
apt update
apt upgrade -y
apt install -y snmpd vim nano apt-utils
chmod 755 /usr/bin/distro
tee /etc/snmp/snmpd.conf <<EOF
com2sec readonly  default         public
group MyROGroup v2c        readonly
view all    included  .1                               80
access MyROGroup ""      any       noauth    exact  all    none   none
syslocation "somewhere"
syscontact me@me
extend . distro /usr/bin/distro
dontLogTCPWrappersConnects yes

Inside the container there is no systemd. You need to create your own start script.

Pi-hole uses s6-init to handle the services: docker-pi-hole/src/s6 at master · pi-hole/docker-pi-hole · GitHub

thanks rdwebdesign for the reply, I have this working now.

For anyone else that finds this, I added the following set of commands to the list of commands I shared above that I run when performing customisation of the image and snmpd now starts on boot:

touch /etc/s6-overlay/s6-rc.d/user/contents.d/snmp
mkdir /etc/s6-overlay/s6-rc.d/snmp
echo oneshot | tee /etc/s6-overlay/s6-rc.d/snmp/type 
tee /etc/s6-overlay/s6-rc.d/snmp/up <<EOF
foreground { echo "starting snmpd..." }
/etc/init.d/snmpd start

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.