# Use a minimal base image FROM alpine:latest # Install necessary packages RUN apk add --no-cache snmpd python3 py3-pip # Install any additional Python packages if needed RUN pip3 install --no-cache-dir random # Copy the custom script into the container COPY custom_snmp_script.py /usr/local/bin/custom_snmp_script.py # Make the script executable RUN chmod +x /usr/local/bin/custom_snmp_script.py # Configure snmpd to use the custom script RUN echo "extend customOID /usr/local/bin/custom_snmp_script.py" >> /etc/snmp/snmpd.conf # Expose the SNMP port EXPOSE 161/udp # Start snmpd with environment variables CMD ["sh", "-c", "snmpd -f -c /etc/snmp/snmpd.conf -Lf /dev/null -p /var/run/snmpd.pid -a -x $SNMP_COMMUNITY"]