【发布时间】:2020-01-16 18:59:52
【问题描述】:
我尝试运行位于 shell 文件中的 dotnet 命令,该命令将在 docker 构建过程中由 dockerfile 调用。
这里是 dockerfile sn-p:
FROM ubuntu:16.04
FROM microsoft/dotnet:2.2-sdk as build-env
# .net core
RUN apt-get update -y && apt-get install -y wget apt-transport-https
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb
RUN apt-get update -y && apt-get install -y aspnetcore-runtime-2.2=2.2.1-1
# dotnet tool command
RUN apt-get update -y && apt-get install dotnet-sdk-2.2 -y
# for dot net tool #https://stackoverflow.com/questions/51977474/install-dotnet-core-tool-dockerfile
ENV PATH="${PATH}:/root/.dotnet/tools"
# Supervisor
RUN apt-get update -y && apt-get install -y supervisor && mkdir -p /etc/supervisor
# main script as defacult command when docker container runs
# Run the main sh script to run script in each xxx/*/db-migrate.sh.
CMD ["/xxx/main-migrate.sh"]
# Microservice files
ADD xxx /xxx
# install the xxx deploy tool
WORKDIR /xxx
RUN for d in /xxx/*/ ; do cd "$d"; if [ -f "./install.sh" ]; then sh ./install.sh; fi; done
在install.sh,代码如下:
dotnet tool install -g xxx.DEPLOY --version [$(cat version)] --add-source /xxx/
当我运行 docker build -t xxx:v0 . 时,我收到一条错误消息:
./install.sh: 1: ./install.sh: dotnet: 未找到
我已经添加了FROM microsoft/dotnet:2.2-sdk as build-env & RUN apt-get update -y && apt-get install dotnet-sdk-2.2 -y,但是为什么Docker在构建过程中找不到dotnet命令?
如何在 docker 构建过程中调用位于 shell 脚本文件中的dotnet 命令?
谢谢
【问题讨论】:
标签: shell docker .net-core dockerfile docker-build