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

Ubuntu虚拟机部署Geonode执行docker-compose build --no-cache报错求助

解决GeoNode Docker构建时apk add失败的问题

问题描述

在Ubuntu虚拟机上部署GeoNode,执行docker-compose build --no-cache时,遇到以下错误:

Dockerfile:3

FROM nginx:1-alpine
>>> RUN apk add --no-cache openssl inotify-tools

4 |
5 | WORKDIR /etc/nginx/
ERROR: failed to solve: process "/bin/sh -c apk add --no-cache openssl inotify-tools" did not complete successfully: exit code: 2
ERROR: Service 'geonode' failed to build : Build failed

解决方案

  • 替换Alpine软件源
    Alpine默认官方源可能存在访问问题,修改Dockerfile,在apk add命令前添加国内镜像源替换:

    FROM nginx:1-alpine
    
    # 替换为阿里云Alpine镜像源
    RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
    RUN apk add --no-cache openssl inotify-tools
    
    WORKDIR /etc/nginx/
    
  • 验证虚拟机网络连通性
    确保Ubuntu虚拟机可以正常访问外网,执行以下命令测试:

    ping dl-cdn.alpinelinux.org -c 3
    

    如果无法连通,检查虚拟机网络设置(NAT/桥接模式)、宿主机网络或防火墙规则,确保网络通畅。

  • 确认软件包可用性
    部分旧版本Alpine镜像可能没有inotify-tools包,可临时进入容器验证:

    docker run -it nginx:1-alpine sh
    apk search inotify-tools
    

    如果搜索不到,将Dockerfile的基础镜像替换为更高版本的Alpine-based nginx镜像,比如:

    FROM nginx:1.25-alpine
    
  • 清理Docker缓存
    清理冗余镜像和缓存后重新构建:

    docker system prune -a
    docker-compose build --no-cache
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 08:43:14