首页 > 解决方案 > 为 .deb 文件创建 dockerfile

问题描述

我想为在 ubuntu 18.04 上运行的 debian 文件扩展名创建一个 dockerfile。到目前为止我已经写了这个

FROM ubuntu:18.04 AS ubuntu

RUN apt-get update

WORKDIR /Downloads/invisily

RUN apt-get install ./invisily.deb

除了最后一个阶段,所有阶段都运行良好。它显示了这个错误:

E: Unsupported file ./invisily.deb given on commandline
The command '/bin/sh -c apt-get install ./invisily.deb' returned a non-zero code: 100

我是码头工人和云的新手,所以任何帮助将不胜感激,谢谢!

编辑:我通过将 dockerfile 和 debian 文件放在同一目录中并使用 COPY 来解决它。./ 这就是我的 dockerfile 现在的样子:

FROM ubuntu:18.04 AS ubuntu

RUN apt-get update

WORKDIR /invisily

COPY . ./

USER root
RUN chmod +x a.deb && \
    apt-get install a.deb


标签: dockerdocker-composedockerfile

解决方案


一些东西,

  • WORKDIR 是容器内的工作目录。
  • 在构建 Docker 映像时,您需要将文件 invisily.deb 从本地复制到您的容器。
  • 您可以在 RUN 字段中传递多个 bash 命令,并将它们与多行结合起来。

尝试这样的事情

FROM ubuntu:18.04 AS ubuntu
WORKDIR /opt/invisily

#Drop the invisily.deb in to the same directory as your Dockerfile
#This will copy it from local to your container, inside of /opt/invisily dir
COPY invisily.deb .

RUN apt-get update && \
    chmod +x invisily.deb && \
    apt-get install invisily.deb

推荐阅读