How to Setup Docker Containers As Build Agents for Jenkins

Поділитися
Вставка

КОМЕНТАРІ • 68

  • @henryborchers1001
    @henryborchers1001 3 роки тому +7

    Dockerfile based agents was the biggest game changer for Jenkins for me.

  • @vinaykumar-qq9wq
    @vinaykumar-qq9wq Рік тому

    Excellent narrative style. Really appreciate your efforts ❤

  • @riteshwalia1295
    @riteshwalia1295 2 роки тому +4

    HI Darin,
    I have my Jenkins running on docker so how do i create the docker build agents. Could you please share what additional configurations are required for that

  • @basamnath2883
    @basamnath2883 5 місяців тому

    Amazing teaching. Just awesome and thank you

  • @kimwkahler7381
    @kimwkahler7381 2 роки тому

    Great video! Automated deployment on a box that only exists while Jenkins is building. Surreal :)

  • @sambasivam
    @sambasivam 2 роки тому +4

    how does it run at agent? is there any additional config settings missing? Everytime I run it will execute in master and throw error docker not found. any help?

  • @mithuntechtraining
    @mithuntechtraining Рік тому +7

    Hi Darin
    You and your videos are awesome and very informative as always. But could you please make a video on how to use docker as dynamic slave agents by building a custom docker image and use that whenever there is requirement in the job.
    Thanks
    Mithun

  • @scribblespoon1919
    @scribblespoon1919 5 місяців тому +2

    Docker was not found. I'm guessing there are some other prerequisits other than the plugins. The documention of the docker pipeline plugin didn't help me as well.

  • @N1mdae
    @N1mdae 2 роки тому +4

    This seems fantastic. One question : If we have Jenkins running as a docker image. Is there any problem or consideration with the setup?

  • @azaifel
    @azaifel 3 роки тому

    Excellent tutorial! thanks

  • @אופקגולדשטיין-ר2ס
    @אופקגולדשטיין-ר2ס 5 місяців тому

    How did you install docker cli on the agent?

  • @RaviSharma-vw7py
    @RaviSharma-vw7py 2 роки тому

    Thanks Darin ! Nice !

  • @bambamty
    @bambamty 7 місяців тому

    I am trying to run ESP-IDF docker with a 'build-wrapper' inside of it to generate build files for an ESP32. When I do this Jenkins complains as it looks like my 'builder' node is running these, when it should be my Docker container. I don't want to install them on the node as then i'll be unable to swap dependencies on a per-project basis. Any help is greatly appreciated!

  • @pazfelipe
    @pazfelipe 3 роки тому +4

    Hi Darin. Could you make a video showing how to execute these steps inside a jenkins docker image?

    • @AndreSantos-hd7iw
      @AndreSantos-hd7iw 2 роки тому +1

      You need to run jenkins container mapping volume to docker socket. That way the docker commands executed inside the container will be executed on the host.
      --volume /var/run/docker.sock:/var/run/docker.sock

    • @s.i.m.c.a
      @s.i.m.c.a 2 роки тому +2

      @@AndreSantos-hd7iw but would you expose the docker.socket to the Agent? it is an security risk. For example, you would able to kill Jenkins agent from the job or any another non-relevant to the Jenkins container.

  • @anthonywhitehead8182
    @anthonywhitehead8182 3 роки тому +2

    Hi Darin, I've been following your examples, thank you. I'm not sure if you answer questions here, but I've got a docker-compose setup with nginx and the blueocean jenkins container (created from ansible) working nicely, along with configuration as code. I'm trying to create a build agent but am stuck with and haven't been able to resolve 'got permission denied while trying to connect to the docker daemon socket'. I'd like the agent to be another docker container in docker-compose based on the inbound-agent container. Am I going around this ok, or should I just give in and create a real vm as an agent rather than a docker one?

    • @sumanta8504
      @sumanta8504 3 роки тому +1

      if you are getting 'got permission denied while trying to connect to the Docker daemon socket' that means Jenkins user does not have the access permission. So in that case add jenkins user in docker group, hope that will resolve the issue

  • @BryanIngking-k2x
    @BryanIngking-k2x 10 місяців тому

    Hi Darren, just wondering if agent1 is running inside a docker container as I am currently seeing errors when trying to follow the guide you made in here?

  • @sebastianfarias5670
    @sebastianfarias5670 2 роки тому

    OMG best video ever ! thank you !!!

  • @JayeshRaina-b8m
    @JayeshRaina-b8m Рік тому

    How can I stop in remoivng the containers in pipline, there is no code to make sure container remains after job is finished.

  • @kushsharma6653
    @kushsharma6653 2 роки тому +3

    Thanks for this awesome video. Keep sharing more! One question: What if I want to use Jenkinsfile-3 with node image, curl and git but I also want to have docker installed on this image? What would be the dockerfile code like? Thanks in the advance. :D

  • @Rahul-hx9dz
    @Rahul-hx9dz 8 місяців тому

    Hey how do I setup windows server which contains docker deamon running in it as agent.. so that I can run my groovy pipeline script in dynamically created container on agent ?

  • @yashhirulkar909
    @yashhirulkar909 2 роки тому

    sir i am getting this error while using docker as agent .What shud i do please?
    failed to register layer: Error processing tar file(exit status 1): open /etc/rdma/modules/roce.conf: no space left on device

  • @digitallova
    @digitallova Рік тому

    what about slave nodes on the cloud? what kind of directives to put to execute a docker agent in a node on the cloud?

  • @aleexdds
    @aleexdds Рік тому

    Amazing Videos

  • @sathishsubramanian2510
    @sathishsubramanian2510 2 роки тому

    Hi Darin, I have a doubt that for building docker image should we need to run jenkins inisde docker container or from war file we can use jenkins?

  • @rohanrustagi7857
    @rohanrustagi7857 Рік тому

    hey can I add docker build stage in the same pipeline ?

  • @nandiniachugatla932
    @nandiniachugatla932 10 місяців тому

    How can we add docker in jenkins image
    ??

  • @anthonywhitehead8182
    @anthonywhitehead8182 3 роки тому

    fantastic content, thank you

  • @master2466
    @master2466 2 роки тому

    What if the docker host is out there on network as opposed to on Jenkins host?

  • @staj
    @staj 2 роки тому

    Brilliantly done. Great Information. Thanks.

  • @rbelatamas
    @rbelatamas 2 роки тому

    thanks this really useful video!

  •  2 роки тому

    how can use this with docker daemon with remote docker ?

  • @vijjisanthi1922
    @vijjisanthi1922 2 роки тому

    Hello Darin currently iam running jenkins from ec2 is there any possibility to move from ec2 to ecs without loosing my data and configuration

  • @lalitshukla6585
    @lalitshukla6585 2 роки тому

    Thanks Sir.. Can we use a Jenkins upstream job to create multiple slaves ? if yes please explain.

  • @StevePrior
    @StevePrior 2 роки тому

    I thought this was a very helpful video, but have a concern about the second example which I found out the hard way. When you have two different agents in play Jenkins creates separate workspaces for each, so any files created by the first maven agent won't be available to the second agent. In my case I had a build stage that used a containerized build tool and I wanted the artifact created by that tool to be available to a second stage which was not running in the docker container. So I ended up using agent any at the toplevel, then specified reuseNode true within the agent of the first stage (which runs the docker container), then no agent specified for the second stage. This resulted in an overall agent workspace for the pipeline, but then the first stage running in a docker container but not creating a new workspace to do so, so the next stage would still be using the same workspace.
    I'm sure I still have lots of tricks to learn, but it would be great if CloudBees produced a video on this.

    • @s.i.m.c.a
      @s.i.m.c.a 2 роки тому

      it's an Jenkins basics - the stages could be executed on a different agents, and you could instruct Jenkins to do it in a parallel.

  • @0kaschei0
    @0kaschei0 2 роки тому

    Thank you

  • @rayc6556
    @rayc6556 2 роки тому

    i am using image jenkins/jenkins:lts-jdk11, and the pipeline gave me error docker: not found. Anyone have the same experience and how to solve?

    • @shilashm5691
      @shilashm5691 2 роки тому

      You are not alone😪

    • @shilashm5691
      @shilashm5691 2 роки тому

      Do you got any solution?

    • @AndreSantos-hd7iw
      @AndreSantos-hd7iw 2 роки тому

      You must create a custom image based on jenkins/jenkins:lts-jdk11 and install docker on it

    • @AndreSantos-hd7iw
      @AndreSantos-hd7iw 2 роки тому

      And run jenkins container mapping volume to docker socket. That way the docker commands executed inside the container will be executed on the host.
      --volume /var/run/docker.sock:/var/run/docker.sock

    • @s.i.m.c.a
      @s.i.m.c.a 2 роки тому

      it's an docker-in-docker concept and before implementing it, you should weight the risks like - all jobs and containers, including the one belongs to agent would be exposed to the user pipeline. Basically user with his own pipeline would be able to manipulate any another user pipeline and shut down the agent itself.
      This stuff could be used only in non-critical environment or in a lab. If it is used in production - get ready to be hacked (especially if there are a different level access to different pipelines)

  • @irfansadiq
    @irfansadiq 2 роки тому

    Will it pick any agent wit label Linux?

    • @sambasivam
      @sambasivam 2 роки тому

      how does it know when it is not specified in the Jenkinsfile?

  • @Sathurjan11
    @Sathurjan11 Рік тому

    Still waiting to schedule task
    Waiting for next available executor

  • @backendjava
    @backendjava 4 місяці тому

    teach how to do it with a docker based jenkins install

  • @danish6192
    @danish6192 3 роки тому

    perfect !

  • @RajaAnbazhagan
    @RajaAnbazhagan Рік тому

    Aha. This one uses the local docker on the available agent to run the stuff. Was confusing it with docker cloud agents themselves.

    • @thecoasterfollower3564
      @thecoasterfollower3564 Рік тому

      How can we run docker commands on the docker cloud agents? All these tutorials including his do it on the built in node which isn’t recommended

  • @Adventurevictoria
    @Adventurevictoria Рік тому

    You have been told that the agent has been installed docker but actually, the agent was running out side of docker as you can see from 5:45 . Im spend over week to find a solution to create docker agent that actually running in side docker and still doing all docker command job include docker compose , currently I was able to run successfully docker command in side docker agent which is running in side docker and build as well but not able to RUN!!!!!! anyone who made it ?????

  • @kayoutube690
    @kayoutube690 7 місяців тому +1

    These the docker build is not work for this tutorial.

  • @thecoasterfollower3564
    @thecoasterfollower3564 Рік тому +1

    But these all run on the built in node? Isnt the point of docker agents to use it on a docker cloud node? And you can't even run docker commands in any of these, where alot of apps are ran on docker in the first place. I don't understand how this is any different from just using docker cloud nodes. I need to run docker inside of the docker cloud nodes themselves, this video is misleading because you still are building on the built in node.

    • @abhijitshubham9730
      @abhijitshubham9730 Рік тому

      Hi @thecoasterfollower3564, were you able to find the solution as to how I can use a Dockerfile to create Docker container as node and then build docker image inside it?

  • @vijjisanthi1922
    @vijjisanthi1922 2 роки тому

    Can u pls help out me on this

  • @connerwhite5351
    @connerwhite5351 Рік тому +3

    docker: not found

    • @weilin4872
      @weilin4872 8 місяців тому

      The same bro, 🤣

  • @andreeliasoliveira6131
    @andreeliasoliveira6131 Рік тому

    Honestly if it weren't for Darin's videos Jenkins would be unusable

  • @girishananda8604
    @girishananda8604 3 роки тому +4

    Sucks! Just polluting internet with lack of info.

  • @shantanuparanjpe8363
    @shantanuparanjpe8363 2 роки тому

    Hi Darin,
    i am trying to run the jenkins pipeline stages inside a docker agent. I am using the centos-8 on my host machine. I am getting below error while running the build
    java.io.IOException: Failed to run top 'fab543e3693ea5258e92d440b2e043d58aaf09c98e25f19e1d85c416ea5f4c93'. Error: Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
    Error: top can only be used on running containers
    Jenkinsfile:
    pipeline {
    environment {
    DOCKERHUB_CREDENTIALS = credentials('dockerhub')
    }
    agent {
    docker {
    image 'ubuntu:latest'
    alwaysPull true
    }
    }
    stages {
    stage('Build') {
    environment {
    HOME="."
    }
    steps {
    script {
    sh '/usr/local/bin/docker build -t test .'
    }
    }
    }
    stage('Login') {
    steps {
    sh 'echo $DOCKERHUB_CREDENTIALS_PSW |/usr/local/bin/docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
    }
    }
    stage('Push') {
    steps {
    script {
    sh '/usr/local/bin/docker push *****/test'
    }
    }
    }
    }
    }

  • @Hakob771
    @Hakob771 2 роки тому

    Here is the issue, who can help?
    I tried agent { dockerfile true }, Jenkins was creating docker container, after that it didn't go through stages, i mean it stuck after creating docker container, job is not ending, minutes are going, but content in steps block dont' work

  • @TheExplorist
    @TheExplorist Рік тому

    + docker inspect -f . node:18.16.0-alpine
    Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? facing even docker desktop everything running and I can build the image from my local computer as well

    • @yukinoryu
      @yukinoryu 2 місяці тому

      if used brew, install docker via brew cask , so run: brew install --cask docker