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

Dockerfile构建镜像时遇Unable to locate package sqlite3错误求助

问题原因及解决办法

问题原因

  • nvidia/cuda:12.2.0-devel-ubuntu20.04基础镜像默认未启用Ubuntu的universe仓库,而sqlite3包存放在该仓库中,直接执行安装会找不到包。
  • 若apt-get update因网络问题未成功刷新源缓存,也会导致后续安装时无法定位到包。

解决办法

方法1:启用universe仓库后安装

在Dockerfile中按顺序执行以下命令,确保启用对应仓库并刷新源:

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository universe && \
    apt-get update && \
    apt-get install -y sqlite3

说明:

  • software-properties-common是管理软件源的工具,add-apt-repository universe负责启用universe仓库。
  • 两次apt-get update分别用于刷新原有源和新增仓库后的源缓存。

方法2:替换为国内Ubuntu源(解决网络问题)

如果服务器访问官方Ubuntu源较慢或失败,可先替换为国内镜像源(如阿里云),再执行安装:

RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    apt-get update && \
    apt-get install -y sqlite3

验证安装

构建完成后进入容器,执行sqlite3 --version,若输出版本信息则说明安装成功。

内容的提问来源于stack exchange,提问作者Ufuk Can Bicici

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 00:20:56