简体   繁体   中英

How to point on the concrete Dockerfile for the docker build command inside the jenkins pipeline?

Please let me know how to point on the concrete Dockerfile for the docker build command inside the jenkins pipeline?

I am trying to give a docker build from a Jenkins pipeline, I am using a common code to run this build and would want the pipeline to access a folder where the dockerfile is. How do I let the docker know how to find this dockerfile which is in a different folder location.

With sh in a declarative pipeline:

sh '''
    docker build -t '<myimagename>' \
        --file <somewhereelse>/Dockerfile .
'''

Within a scripted pipeline :

docker.build("my-image:${env.BUILD_ID}", "-f ${dockerfile} ./dockerfiles")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM