Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

628
Views
how to configure jenkins to execute the docker commands in remote machine?

We have a Jenkins master server and where we have installed docker as well. Also we have other 3 remote vms with docker installed on them,

Our requirement here in Jenkins to do below things.

1)Jenkins should create image from the committed docker file in git

2) Jenkins should push this image to the DTR

3) Jenkins should launch these pushed images to the containers in the remote vms.

What are the possible ways to do.

How to configure Jenkins to run the containers in the remote vms?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

There are alot of ways to achieve this, what fits best will depend on your requirements. The following is very simple and just executes shell commands on different jenkins-agents.

If those vms are connected to your jenkins master as agents, you are free to checkout your Dockerfile and build on one agent (or master), then switch agents and launch your image there.

Along the lines of the following snipped

def image = 'image123:latest'

node('build-vm') {
  stage('Checkout') {
    checkout scm
  }

  stage('Build image') {    
    sh "docker build -t ${name} ."
    [...] 
    sh 'docker push ${name}'
  }
}

node('vm1') {
  stage('Run image on vm1') {
    sh 'docker run -d ${name}'   
  }
}

node('vm2') {
  stage('Run image on vm2') {
    sh 'docker run -d ${name}'   
  }
}

node('vm3') {
  stage('Run image on vm3') {
    sh 'docker run -d ${name}'   
  }
}
over 4 years ago · Santiago Trujillo Report

0

Ideally, you would use the Jenkins Kubernetes plugin in order to execute jobs on any remote VM Jenkins agents, where kubectl has been installed.

That allows a Docker in Docker build: from "Building Docker Images inside Kubernetes" written by Vadym Martsynovskyy.

https://cdn-images-1.medium.com/max/1091/1*15NQIPeVcPyZbLq9UCTQgg.png

You also have other options, detailed in "Pipelines With Docker Alternatives" from "Joost van der Griendt's CI/CD Knowledge Docs!", using either:

  • externals nodes (with the JENKINS Amazon EC2 Plugin): not your case
  • Maven JIB, with JIB allowing you to build optimized Docker and OCI images for your Java applications without a Docker daemon
  • Kaniko, which is a tool to build container images from a Dockerfile, inside a container or Kubernetes cluster.
  • or Img, which is a standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder

The main point is: build docker containers with Jenkins is often done in a Kubernetes setup context.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!