gpt4 book ai didi

docker - 在 Docker 构建期间安装 Homebrew 软件包

转载 作者:行者123 更新时间:2023-12-01 12:05:34 25 4
gpt4 key购买 nike

我正在尝试安装 docker 镜像,并希望在运行容器时预安装某些 Homebrew 软件包。我能够很好地构建它并且版本语句按预期工作,但是当我运行时安装的包丢失了。知道我做错了什么吗?

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 环境变量:

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

这是一个完整的工作 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 - 在 Docker 构建期间安装 Homebrew 软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57739378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com