[英]ERROR: Service 'ubuntu' failed to build: The command '/bin/sh -c apt-get update
[英]Docker build error /bin/sh: 1: apt-get: not found
我試圖構建 docker 鏡像,但有這個問題 這是我的 dockerfile
FROM ubuntu:16.04
MAINTAINER Noon qop.box@gmail.com
RUN apt-get update && \ apt-get -y git
CMD /bin/bash
多余的反斜杠導致apt-get
前面的空格按字面意思處理,而不僅僅是將命令名稱與&&
分開。 這意味着您正在嘗試運行名為<space>apt-get
的命令。 只需省略反斜杠。
# And add the install command to the second call to apt-get
RUN apt-get update && apt-get install -y git
反斜杠僅在您想將RUN
命令分成兩行時才需要,例如
RUN apt-get update && \
apt-get install -y git
其中反斜杠在 Dockerfile 中充當行的延續; 它不是命令本身的一部分。
正如@tgogos 在評論中回答的那樣,您可以嘗試
RUN apt-get update && apt-get install -y git
但是如果你想使用多行,你也可以這樣使用
RUN apt-get update \
&& apt-get install -y git \
&& <other command under RUN> \
&& <and so on>
@chepner 對多線樣式的看法也是正確的
如果您使用不同的 Unix 發行版,可能會發生類似的錯誤。 就我而言,我將apt-get
更改為apk
,這對我apk
。
使用conda install -c anaconda git 對我有用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.