Has anyone had any luck with running docker images from workflow steps?
I am trying to build and run a docker container using the workflow plugin.
I have a simple Spring Boot app running as a JAR file within a Docker
container. I am trying to use the workflow plugin to make a Docker
container with my JAR file and then run the docker file.
My Jenkins host is currently my Docker Engine. This will change later when
I get this working. I'll have the local Docker client point to a different
engine, possibly a Docker Swarm.
I am struggling with having the workflow script be able to locate my
Dockerfile.
*The error I am getting is as follows:*
Running: Shell Script
[workspace] Running shell script
+ docker build -t kentoj/sksvc:1.1 .
time="2015-03-26T16:13:08-06:00" level="fatal" msg="Cannot locate Dockerfile:
Dockerfile"
*Here is my flow.groovy:*
node('master') {
//input("Ready to start build?")
checkout([
$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs:
[[credentialsId: '.......',
url: 'http://githubenterprise.local/kent/sksvc.git']]])
// BUILD
sh "gradle clean build"
echo 'Building JAR finished.'
echo '...'
echo '...'
echo 'archiving jar file...'
// ARCHIVE JAR FILE
step([$class: 'hudson.tasks.ArtifactArchiver', artifacts:
'**/build/libs/*.jar', fingerprint: true])
echo 'Successfully archived JAR.'
echo 'archiving dockerfile'
// ARCHIVE DOCKERFILE
step([$class: 'hudson.tasks.ArtifactArchiver', artifacts: 'Dockerfile',
fingerprint: false])
echo 'successfully archived dockerfile'
// AGGREGATE TEST RESULTS
step([$class: 'JUnitResultArchiver', testResults:
'**/build/test-results/TEST-*.xml'])
// DEPLOY TO HOST
// sh "scp **/build/libs/*.jar kent@node-app-01:/opt/kent/skeleton"
// CLEAN UP OLD BINARY
// sh "ssh kent@node-app-01 pkill -f \"/opt/kent/skeleton/skeleton*\""
// Build Docker image
sh "docker build -t kentoj/sksvc:1.1 ."
// Run Docker container
sh "docker run -d=true -p 8090:8080 --name kent-sksvc kentoj/sksvc:1.2 &"
}
*My docker file is as follows:*
# skeleton service
#
# Version 0.0.1
FROM java:8u40-jre
MAINTAINER Kent Johnson <[email protected]>
ADD skeleton-service-0.0.1.jar /opt/kent
WORKDIR /opt/kent
CMD java -jar *.jar
# ENTRYPOINT["/usr/bin/java", "-jar", "/opt/kent/*.jar"]
EXPOSE 8080;
How would I be able to retrieve the Dockerfile and, further, how would I know
which context to execute the `docker build` command from?
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/5de21093-b724-4d50-9e80-2e2411e26a41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.