How to execute commands in container from Jenkins

Hello,

I’m new in rancher/docker world, and i am trying to find the best way to execute commands from Jenkins in an existing container (mainly bash and php commands), in order to use Jenkins as a job scheduler.

In my old infra, i was doing this by using “Execute SSH on a remote server”. But i read that’s it’s not the best way to achieve this when using docker, and that’s it’s better to use docker exec.

So what’es your advice to achieve this ? At the moment, i was figuring those scenariis :

  1. Installing openssh server on my app container, and SSH it from Jenkins using a link
  2. SSH on the host where the container app is running and use “docker exec” . But the difficulty will be to know where the container is hosted everytime the build is running in Jenkins
  3. Any ideas ? :slight_smile:

Thanks a lot for your help

Probably the easiest thing would be to install the rancher cli tool on your jenkins box and give it credentials. Then you can use rancher exec to connect to containers running inside rancher.