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

Docker Compose启动容器执行chown报错:No such file or directory

问题解决:Docker Compose command 执行报错 "No such file or directory"
  • 错误原因:用数组格式定义command时,必须把每个命令参数拆成独立的数组元素。你当前的写法把整个命令串作为单个元素,Docker会尝试直接执行这个完整字符串对应的文件,自然找不到。

  • 修正后的完整配置:

services:
  unbound-db-socket:
    image: busybox:latest
    container_name: unbound-db-socket
    init: true
    tty: true
    command: ["/bin/sh", "-c", "chown -R 1000:1000 /usr/local/unbound/cachedb.d/"]
    volumes:
       - "cachedb.d:/usr/local/unbound/cachedb.d/"

volumes:
  cachedb.d:

networks:
  bridge:
  • 补充说明:
    • 数组格式下,/bin/sh是第一个元素,-c是第二个,后续的命令字符串是第三个元素,这样Docker才会正确调用shell执行指定命令。
    • 也可以直接用字符串格式简化写法:command: /bin/sh -c "chown -R 1000:1000 /usr/local/unbound/cachedb.d/",这种情况下Docker会自动帮你拆分参数。

内容的提问来源于stack exchange,提问作者Brunn

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 22:00:54