Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

629
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda