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

Docker编译OnlyOffice遇./make.py权限拒绝问题求助

Docker编译OnlyOffice时./make.py: Permission denied错误排查与解决

问题场景

在Docker容器(root用户)中编译OnlyOffice,执行python3 ./automate.py server时触发/bin/sh: 1: ./make.py: Permission denied错误,已确认make.py权限且尝试chmod -X make.py无效。

环境信息

  • 复现步骤:执行python3 ./automate.py server
  • build_tools版本:origin/release/v8.1.0
  • 宿主机OS:Linux 4.4.0-186-generic (Ubuntu 16.04, gcc 5.4.0)
  • 编译器版本:master版本
  • Dockerfile内容:
    FROM ubuntu:16.04
    
    ENV TZ=Etc/UTC
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    
    # Update the sources.list to use the mirror closet to you
    RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://free.nchc.org.tw/ubuntu/|g' /etc/apt/sources.list
    
    RUN apt-get -y update && \
        apt-get -y install software-properties-common && \
        add-apt-repository ppa:openjdk-r/ppa && \
        apt-get -y update && \
        DEBIAN_FRONTEND=noninteractive apt-get -y install python \
                                        python3 \
                                        sudo \
                                        openjdk-11-jdk \
                                        openjdk-11-jdk-headless \
                                        openjdk-11-jre \
                                        openjdk-11-jre-headless \
                                        git \
                                        openssh-client
    
    RUN rm /usr/bin/python && ln -s /usr/bin/python2 /usr/bin/python
    
    VOLUME ["/work"]
    WORKDIR /work
    
    # Set the default command
    CMD ["bash"]
    
  • 关键错误日志片段:
    HEAD is now at 8a2fdfe... replace archaic &std::vector::operator[0] with c++11 std::vector::data
    /bin/sh: 1: ./make.py: Permission denied
    [fetch & build]: boost
    ...
    Error (./make.py): 126
    ...
    Error (./make.py): 1
    

可能原因

  • 权限命令参数错误:使用chmod -X make.py是移除执行权限的操作,而非添加,参数完全搞反。
  • 挂载目录权限限制:/work是宿主机挂载目录,若宿主机文件系统(如WSL共享Windows目录)或挂载选项包含noexec,容器内即使设置执行权限也无法执行脚本。
  • shebang缺失/错误:make.py文件开头未添加正确的shebang(如#!/usr/bin/env python3),系统无法识别脚本解释器,触发权限类错误。
  • Git克隆丢失权限:克隆仓库时Git未保留文件的执行权限位,导致make.py默认无执行权限。

解决方法

  1. 修正权限设置命令
    执行正确的添加执行权限命令:

    chmod +x /work/build_tools/tools/linux/make.py
    

    确认权限生效:

    ls -l /work/build_tools/tools/linux/make.py
    

    输出需包含-rwxr-xr-x或类似带x的权限标识。

  2. 检查挂载目录的exec权限

    • 宿主机执行mount命令,查看/work对应挂载点是否带有noexec选项,如有则重新挂载:
      mount -o remount,rw,exec /path/to/host/work
      
    • 若为WSL共享Windows目录,修改/etc/wsl.conf开启权限支持:
      [automount]
      options = "metadata,umask=22,fmask=11"
      
      重启WSL后生效。
  3. 添加/修正shebang
    编辑make.py,在文件第一行添加正确的shebang:

    echo '#!/usr/bin/env python3' | cat - /work/build_tools/tools/linux/make.py > temp.py && mv temp.py /work/build_tools/tools/linux/make.py
    

    完成后重新设置执行权限。

  4. 重新克隆仓库并保留权限
    克隆时确保Git保留文件权限:

    git clone --branch release/v8.1.0 --no-single-branch https://github.com/ONLYOFFICE/build_tools.git
    

    克隆后直接检查make.py权限是否正常。

  5. 在Dockerfile中预配置权限
    若构建镜像时克隆仓库,可在Dockerfile中添加权限设置步骤:

    RUN git clone --branch release/v8.1.0 https://github.com/ONLYOFFICE/build_tools.git /work/build_tools && \
        chmod +x /work/build_tools/tools/linux/make.py
    

内容的提问来源于stack exchange,提问作者E.M.T

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 03:14:53