0

I have just started working with Jenkinsfiles and Docker so apologies if this is something obvious.

I have a repo containing a Dockerfile and a Jenkins file.

The Dockerfile simply extends a base Ubuntu image (ubuntu:trusty) by adding several dependencies and build tools.

The Jenkinsfile currently only builds the Docker container for me:

node('docker') {
stage "Prepare environment"
    checkout scm
    docker.build('build-image')
}

When I run the Jenkins build, the output log shows the Docker container being successfully created, but just before it should finish successfully, I get:

Successfully built 04ba77c72c74
[Pipeline] dockerFingerprintFrom
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[Bitbucket] Notifying commit build result
[Bitbucket] Build result notified
ERROR: could not find FROM instruction in /home/emackenzie/jenkins/workspace/001_test-project_PR-1-ROWUV6YLERZKDQWCAGJK5MQHNKY7RJRHC2TH4DNOZSEKE6PZB74A/Dockerfile
Finished: FAILURE

I have been unable to find any guidance on why I am getting this error from the internet, so any help would be greatly appreciated


Dockerfile:

FROM    ubuntu:trusty
MAINTAINER Ed Mackenzie

# setup apt repos
RUN echo "deb http://archive.ubuntu.com/ubuntu/ trusty multiverse" >> /etc/apt/sources.list \
&& echo "deb-src http://archive.ubuntu.com/ubuntu/ trusty multiverse" >> /etc/apt/sources.list \
&& apt-get update

# python
RUN apt-get install -y python python-dev python-openssl
4

3 回答 3

3

我刚刚遇到了同样的问题,这是一个类似的解决方案。检查文件是否在文件开头使用BOM进行编码(这可以使用 Notepad++ 之类的东西来完成)。如果是这样,请在没有标记的情况下保存它,插件将停止抱怨。

于 2017-05-24T21:23:30.457 回答
3

这是因为您的FROM行使用制表符代替空格,而不是空格。这是 Jenkins CI Docker 工作流插件中的一个错误,它要求该行以FROM空格开头。

来自 Github 上的jenkinsci/docker-workflow-plugin源代码:

String fromImage = null;

// ... other stuff

if (line.startsWith("FROM ")) {
    fromImage = line.substring(5);
    break;
}

// ... other stuff ...

if (fromImage == null) {
    throw new AbortException("could not find FROM instruction in " + dockerfile);
}

如果您使用空格而不是制表符,它应该可以正常工作。

于 2017-02-01T18:22:35.137 回答
1

该错误可以通过将“from”语句更改为“FROM”来解决

于 2018-12-12T20:45:14.660 回答