Docker构建步骤:刷新用户配置文件/会话



我有一个安装.NET 5 SDK的docker文件,然后尝试使用dotnet tool install安装一个工具。

这样做后,我得到警告:

由于您刚刚安装了.NET SDK,在运行安装的工具之前,您需要注销或重新启动会话。

如何在docker构建过程中注销或重新启动会话

我试过RUN echo "export PATH=/new/path:${PATH}" >> /root/.bashrc,但似乎没有什么区别。


配对示例:

FROM ubuntu as base-updates
RUN apt-get install -y wget
RUN wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN apt-get update; 
apt-get install -y apt-transport-https && 
apt-get update && 
apt-get install -y dotnet-sdk-5.0
RUN dotnet tool install --global Amazon.Lambda.Tools
## executing the newly installed tool fails
RUN dotnet lambda --help

从https://github.com/dotnet/dotnet-docker/issues/520(非常感谢@myeongkilkim!(:

显式更新PATH确实奏效:ENV PATH="${PATH}:/root/.dotnet/tools"

FROM ubuntu as base-updates
RUN apt-get install -y wget
RUN wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN apt-get update; 
apt-get install -y apt-transport-https && 
apt-get update && 
apt-get install -y dotnet-sdk-5.0
# FIX:
# manually add dotnet tools path to path variable
# https://github.com/dotnet/dotnet-docker/issues/520
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet tool install --global Amazon.Lambda.Tools
## executing the newly installed tool now works :)
RUN dotnet lambda --help

相关内容

  • 没有找到相关文章