Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

630
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda