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

构建基于Alpine的Firebase CLI Docker镜像时遇exec格式错误求助

解决基于Alpine的Firebase CLI Docker镜像运行时的exec format error

你的Dockerfile里存在一个关键的wget参数误用,这是触发exec format error的核心原因:

你使用了wget --output-file /usr/local/bin/firebase https://firebase.tools/bin/linux/latest,但--output-file(缩写-o)是用来指定wget的日志输出文件,并非将下载的二进制内容保存到目标路径。这导致/usr/local/bin/firebase实际是wget的日志文本,而非Firebase CLI的可执行程序,执行时自然会出现格式错误。

修正方案

将wget命令中的--output-file替换为--output-document(缩写-O,大写字母O),该参数用于指定下载文件的保存路径:

FROM alpine
RUN apk update; \
  apk add --no-cache openjdk21-jre; \
  wget --output-document /usr/local/bin/firebase https://firebase.tools/bin/linux/latest; \
  # 也可使用更简洁的缩写形式:wget -O /usr/local/bin/firebase https://firebase.tools/bin/linux/latest; \
  chmod +x /usr/local/bin/firebase;
EXPOSE 9099
EXPOSE 8080
EXPOSE 5000
EXPOSE 5001
EXPOSE 8085
EXPOSE 9000
EXPOSE 9199
EXPOSE 9299
EXPOSE 4000
VOLUME [ "/opt/firebase" ]
WORKDIR /opt/firebase
CMD [ "firebase" ]

验证方法

修正后如果仍有疑问,可以运行临时容器检查文件类型,确认下载的是正确的可执行二进制:

docker run --rm <你的镜像名称> file /usr/local/bin/firebase

正常输出应显示类似ELF 64-bit LSB executable, x86-64(x86架构)或对应ARM架构的标识,若显示文本文件类型,则说明下载操作仍有问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 22:30:12