【问题标题】:FROM requires one or three arguments DockerFROM 需要一到三个参数 Docker
【发布时间】:2018-06-24 07:28:32
【问题描述】:

我跑docker build -t imagename .

我收到以下错误:

 Step 1/1 : FROM ubuntu:14.04 
 ENV MAVEN_VERSION 3.3.9 RUN mkdir -p /usr/share/maven \ 
 && curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \ | 
 tar -xzC /usr/share/maven --strip-components=1 \
 && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn ENV MAVEN_HOME 
 /usr/share/maven VOLUME /root/.m2 CMD ["mvn"]
        **FROM requires either one or three arguments**

谁能告诉我应该怎么解决这个问题。我从 17.12 降级到 17.06,这样我在构建时就不会得到Bad Response from Docker Enginer。其他人工作正常。我可以提取并运行其他图像。我无法建造。请帮助并提出修复建议,谢谢!

我的 docker 版本是

Docker version 17.06.2-ce, build cec0b72

Docker 信息是:

 Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 1
Server Version: 17.06.2-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 6e23458c129b551d5c9871e5174f6b1b7
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.41-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: moby
ID: 3S5I:DUOJ:EBRI:PRH6:VMBJ:6H3K:OBZB:HFH7:7RSH:XEO5
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 15
 Goroutines: 26
 System Time: 2018-01-15T16:10:58.5589804Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Docker 文件是:

FROM ubuntu:14.04
ENV MAVEN_VERSION 3.3.9

RUN mkdir -p /usr/share/maven \
  && curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
    | tar -xzC /usr/share/maven --strip-components=1 \
  && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

ENV MAVEN_HOME /usr/share/maven

VOLUME /root/.m2

CMD ["mvn"] 

【问题讨论】:

  • 错误消息似乎表明 Docker 将您的整个 Dockerfile 视为一行。您提供的 sn-p 具有正确的行终止符 - 原始文件也是如此吗?
  • 您在 dockerfile 中使用了哪些行尾字符?

标签: java docker dockerfile docker-build


【解决方案1】:

尝试使用 ARG,而不是仅仅使用

FROM ubuntu:14.04
ENV MAVEN_VERSION 3.3.9

改成

FROM ubuntu:14.04
ARG MAVEN_VERSION=3.5.9

【讨论】:

  • 当然..很高兴能帮上忙..如果这个答案解决了您的问题,请考虑通过单击复选标记接受它。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。没有义务这样做。
【解决方案2】:

虽然这与 OP 遇到的问题的原因不同,但我在按照教程操作后遇到了完全相同的错误。

原来所说的教程在每个配置行的末尾都有 cmets,例如 FROM python:3 # 基础镜像

删除 cmets 后,一切都很好(事实证明,'#' 必须在评论的开头,如 here 所讨论的那样)。

【讨论】:

    【解决方案3】:

    在我的例子中,这个错误是由于在 Windows 上有一个带有 CR 行尾的 Dockerfile 引起的。转换为 CRLF 或 LF 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-16
      • 2021-07-18
      • 2023-03-16
      • 2015-05-13
      • 2020-04-08
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多