You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unraid Docker环境下Telegraf镜像中以Root身份通过Post Argument执行APT安装工具失败的解决方案咨询

Fixing Permission Denied When Installing Tools via Post Argument in Unraid's Telegraf Docker

First, let's get to the root of your error: the official telegraf:latest image runs as the non-root telegraf user by default. That's why your apt commands are throwing a "Permission denied" error—regular users don't have access to system-level package management tools.

Here are two straightforward ways to run your installation commands as root in Unraid's Docker environment:

Method 1: Force Root User + Update Post Arguments

This is the quickest fix for your existing setup:

  1. Open your Telegraf Docker template in Unraid, head to the Advanced Settings section, and find the Extra Parameters field.
  2. Add this line to force the container to start as root:
    -u root
    
  3. Update your post argument command (you can combine multiple apt install calls to make it cleaner):
    /bin/sh -c 'apt update && apt install -y smartmontools lm-sensors nvme-cli ipmitool telegraf'
    
    The container will now run with root privileges, so the apt commands should execute without permission issues.

Method 2: Custom Entrypoint Script (More Persistent)

If you want a maintainable setup that survives container recreates, use a custom entrypoint:

  1. On your Unraid server, create a script file at /mnt/user/appdata/telegraf/custom-entrypoint.sh with these contents:
    #!/bin/sh
    # Create the missing apt directory if needed
    mkdir -p /var/lib/apt/lists/partial
    # Install required tools
    apt update && apt install -y smartmontools lm-sensors nvme-cli ipmitool
    # Launch the original Telegraf entrypoint
    exec /entrypoint.sh "$@"
    
  2. Make the script executable via Unraid's terminal:
    chmod +x /mnt/user/appdata/telegraf/custom-entrypoint.sh
    
  3. Back in your Docker template:
    • Add a volume mapping: /mnt/user/appdata/telegraf/custom-entrypoint.sh → /custom-entrypoint.sh
    • Set the Entrypoint field to /custom-entrypoint.sh
    • Add -u root to the Extra Parameters (still needed for apt access)

Quick Troubleshooting Note

If you still hit issues with the /var/lib/apt/lists/partial directory, explicitly create it in your command (like we did in the entrypoint script):

/bin/sh -c 'mkdir -p /var/lib/apt/lists/partial && apt update && apt install -y smartmontools lm-sensors nvme-cli ipmitool telegraf'

内容的提问来源于stack exchange,提问作者Da Doo Ron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 23:27:34