在Docker构建期间安装自制程序包

在Docker构建期间安装自制程序包

本文介绍了在Docker构建期间安装自制程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装docker镜像安装程序,并希望在运行容器时预先安装某些Homebrew软件包.我能够很好地构建它,并且版本声明可以按预期运行,但是当我运行安装的软件包时,它们丢失了.知道我在做什么错吗?

I am trying to install setup a docker image and want certain Homebrew packages pre-installed when I run the container. I am able to build it just fine and version statements are working as expected but when I run the installed packages are missing. Any idea what I am doing wrong?

RUN git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew \
&& mkdir ~/.linuxbrew/bin \
&& ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin \
&& eval $(~/.linuxbrew/bin/brew shellenv) \
&& brew --version \
&& brew tap aws/tap && brew install aws-sam-cli \
&& sam --version

推荐答案

您必须使用以下命令在Dockerfile中设置PATH环境变量:

You have to set the PATH environment variable in the Dockerfile with:

ENV PATH=~/.linuxbrew/bin:~/.linuxbrew/sbin:$PATH

这是一个完整的工作Dockerfile:

Here is a complete working Dockerfile:

FROM debian
RUN apt-get update && apt-get install -y git curl binutils clang make
RUN git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew \
&& mkdir ~/.linuxbrew/bin \
&& ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin \
&& eval $(~/.linuxbrew/bin/brew shellenv) \
&& brew --version \
&& brew tap aws/tap && brew install aws-sam-cli \
&& sam --version
ENV PATH=~/.linuxbrew/bin:~/.linuxbrew/sbin:$PATH

这篇关于在Docker构建期间安装自制程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 22:42