Is there a way to override the default dockerfile when i try to build a container using build in a jenkins pipeline

0 votes

Using a docker pipeline plugin i'm trying to build a container using build () method in a jenkins pipeline. Is there a way to override the default dockerfile?

Jul 9, 2019 in Docker by Jenny
2,251 views

1 answer to this question.

0 votes

You can pass other arguments to docker build by adding them to the second argument of the build() method. When passing arguments this way, the last value in the that string must be the path to the docker file.

This example overrides the default Dockerfile by passing the -f flag:

node {
    checkout scm
    def dockerfile = 'Dockerfile.test'
    def customImage = docker.build("my-image:${env.BUILD_ID}", "-f ${dockerfile} ./dockerfiles") 
}

This code snippet builds my-image: ${env.BUILD_ID} from the Dockerfile found at ./dockerfiles/Dockerfile.test.

answered Jul 9, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

0 votes
4 answers
+1 vote
1 answer

How do i install jenkins using a dockerfile on a windows container?

Here is to how you can install JENKINS ...READ MORE

answered Aug 22, 2019 in Docker by Sirajul
• 59,230 points
5,862 views
+1 vote
0 answers

How can I map a docker location to my Jenkins workspace so that I can use the files in my Jenkins

Hey guys, I was trying to execute few ...READ MORE

Feb 25, 2020 in Docker by dineshkumar
• 130 points
4,637 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,090 points
2,472 views
0 votes
1 answer

Build a container in Jenkins via "docker pipeline plugin"

In order to create a Docker image, ...READ MORE

answered Jul 9, 2019 in Docker by Sirajul
• 59,230 points
8,139 views
0 votes
1 answer

Why do I get Connection reset by peer when making a request to a service running in a container?

Typically, this message is returned if the ...READ MORE

answered Jul 10, 2019 in Docker by Sirajul
• 59,230 points
4,081 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP