Jenkinsfile custom docker container "could not find FROM instruction"
how to configure docker in jenkins
docker jenkins tutorial
jenkins docker plugin
run/docker image in jenkins pipeline
jenkins build inside a docker container
jenkins pipeline remove docker image
jenkins docker image
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
It's because your FROM
line uses a tab for whitespace, instead of space(s). This is a bug in the Jenkins CI Docker workflow plugin, which expects the line to begin with FROM
followed by a space.
From the jenkinsci/docker-workflow-plugin source on Github:
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); }
If you use spaces instead of tabs, it should work fine.
Jenkins and Docker : Build a Docker image using an jenkins , This post is your guide for building a Docker image, and then setting up Jenkins 2 to build For this we'll write a Jenkins Pipeline specification in a Jenkinsfile . This tool allows packaging custom Jenkins distributions as WAR files, Docker images and Jenkinsfile Runner bundles. This tool allows packaging Jenkins, plugins, and configurations in a ready-to-fly distribution. Custom WAR packager is a part of the Ephemeral Jenkins master toolchain which we presented in our A Cloud Native Jenkins blogpost.
I just ran in to the same problem and it was a similar solution. Check if the file is encoded with a BOM at the beginning of the file (this can be done with something like Notepad++). If so, save it without the marker and the plugin will stop complaining.
Add example showing how to build project inside docker container , First, create the file named Jenkinsfile and specify the first stage. In this stage, we are telling Jenkins to use a Maven image, specifically version This tool allows packaging custom Jenkins distributions as WAR files, Docker images and Jenkinsfile Runner bundles. This tool allows packaging Jenkins, plugins, and configurations in a ready-to-fly distribution. Custom WAR packager is a part of the Ephemeral Jenkins master toolchain which we presented in our A Cloud Native Jenkins blogpost.
The error can be solved by changing the "from" statement to "FROM"
Building your first Docker image with Jenkins 2: Guide for developers, stage('Build image') { steps { echo 'Starting to build docker image' script for key in Jenkis under which you store credentials to your docker registry. PRIVATE_REGISTRY_URL stands for url of your private docker registry. The updated statement in my Jenkinsfile is: return docker.build("db", "-f docker/db/Dockerfile .") And this allows my container to build without modifying the expected context of the developer's docker-compose or Dockerfiles.
Building with Docker Using Jenkins Pipelines, If you're running Docker, the simplest way to run Jenkins is by means of a script like the following. 1 2 3 4 5 6 7 8 9 10, #!/bin/sh docker pull Jenkinsfile Docker pipeline multi stage. Using a Jenkinsfile to configure the Jenkins build job for source code is great. Jenkins has a very nice Docker Pipeline plugin that makes it possible to execute docker commands nicely during the build.
How to build docker images using a Declarative Jenkinsfile, Like inside , run and withRun record the fact that the build used the specified image. Specifying a custom registry and server. So far we have assumed that you are 27 September 2016 on continuous__delivery, docker, jenkins, pipeline. I had a simple case: a build which creates some database Docker container so that integration tests can run against it - using Docker Compose for example
Jenkinsfiles for Beginners and Masochists, Dockerhub is a public docker registry to store your docker images inside. If you want a private registry, you can pay for it. We will use it because it Note: There is more than one docker plugin for Jenkins. While this can be confusing for end-users, it's even more confusing when end users report bugs in the wrong place. e.g. if you are using Jenkins pipeline / workflow / Jenkinsfile builds with code including terms like docker.withDockerRegistry or docker.image etc then you're using the docker-workflow plugin and should go to its repository
Comments
- can you show a failure/pass case to support your answer?
- Can confirm this fixed it for me.