Controlling Docker Containers in Jenkins Pipeline

Hello everyone,

I’ve been able to create a few robot test files that run in a docker image and have also successfully created a Jenkins file that takes all my robot files, starts docker image, and runs tests. All of that is great; however, there is one thing I haven’t been able to figure due to my lack of experience.

I want to create a robot test file that can start/stop a docker container while running inside Jenkins. Locally in my computer, I can use the Process library to run docker command from CLI and it works fine. However, from my research, it seems this is not possible when running robot file in Jenkins because you lose access to those container due to security reasons. Essentially, using Run Process keyword does not work in Jenkins and was wondering if there’s a way I can get around this? I hope this make sense and I would be more than happy to answer any questions. Thank you in advance for your help !

Here are my experiments if I was in your scenario:

  • Try to use can use SSHLibrary to run the commands
  • Try to use Docker plugin in Jenkins (maybe not what you want)
  • Try to change the container to have a daemon looking for a certain file in the shared directory.
  • Use your computer as a node of Jenkins, with access to the container/commands.

Hi Hélio Guilherme,

Thank you so much for your help! I went down the list you provided to see which solution worked with that I was looking for. I ended up changing the container to have a docker daemon.

1 Like