gpt4 book ai didi

docker - 命令在heroku命令行上有效,但在推送的docker镜像中无效

转载 作者:行者123 更新时间:2023-12-02 19:47:54 25 4
gpt4 key购买 nike

我有以下Dockerfile:

FROM ubuntu:latest
RUN apt-get -qq update && apt-get -qq -y install wget\
&& wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
&& chmod a+x lein \
&& cp lein /usr/bin

RUN "lein -v"

从URL下载lein,并将其放在/ usr / bin中。但是仍然 RUN lein -v命令不起作用。
我得到错误:
remote: Step 18/22 : RUN lein -v        
remote: ---> Running in e5f404275fe2
remote: /bin/sh: 1: lein -v: not found
remote: The command '/bin/sh -c lein -v' returned a non-zero code: 127
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to appname
在Heroku一次性dyno本身上,该命令有效。
$ / bin / sh -c“lein -v”

最佳答案

问题是docker RUN期望命令未加引号,按原样或作为命令及其参数的数组:RUN lein -vRUN ["lein", "-v"]之一应该可以解决问题。
另一个问题是您的镜像没有安装Java,因此该命令仍然会失败。因此,您需要以某种方式安装它。您最终的Dockerfile可能如下所示:

FROM ubuntu:latest
RUN apt-get -qq update && apt-get -qq -y install wget\
&& wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
&& chmod a+x lein \
&& cp lein /usr/bin

RUN DEBIAN_FRONTEND=noninteractive \
apt-get -y install default-jre-headless && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN ["lein", "-v"]
-编辑-
实际上,添加java依赖项并更改为 RUN ["lein", "-v"]也不起作用。这些是Dockerfile的前十五个步骤:
ARG CLOJURE_TOOLS_VERSION=1.10.1.507

RUN apt-get -qq update && apt-get -qq -y install curl wget bzip2 openjdk-8-jdk-headless\
&& curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh \
# && curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o /tmp/miniconda.sh \
&& bash /tmp/miniconda.sh -bfp /usr/local \
&& rm -rf /tmp/miniconda.sh \
&& conda install -y python=3 \
&& conda update conda \
&& curl -o install-clojure https://download.clojure.org/install/linux-install-${CLOJURE_TOOLS_VERSION}.sh \
&& chmod +x install-clojure \
&& ./install-clojure && rm install-clojure \
# no need to install lein
&& wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > /usr/bin/lein \
&& chmod 777 /usr/bin/lein \



&& apt-get -qq -y autoremove \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log \
&& conda clean --all --yes

ENV PATH /usr/bin:$PATH
ENV NODE_VERSION=12.18.1
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version




# ENV PATH /opt/conda/bin:$PATH

# RUN conda create -n pyclj python=3.7 && conda install -n pyclj numpy mxnet \
# && conda install -c conda-forge opencv
# ## To install pip packages into the pyclj environment do
# RUN conda run -n pyclj python3 -mpip install numpy opencv-python

FROM openjdk:8-alpine

RUN ["lein", "-v"]

它给出了错误
remote: Step 15/19 : RUN ["lein", "-v"]        
remote: ---> Running in b817213d45b5
remote: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"lein\": executable file not found in $PATH": unknown
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to

关于docker - 命令在heroku命令行上有效,但在推送的docker镜像中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62567252/

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