Rundeck – Run Docker container

Posted: January 4, 2019 in docker, RunDeck

In previous article we configured email monitoring by Zabbix, in this one we’ll schedule python script for sending data to Zabbix, to be run from Docker container
Docker image is created from this file, script will be copied to Docker container, and zabbix agent will be installed

FROM python:3.7.2-stretch

RUN wget apt-get update -y && apt-get install zabbix-agent -y && mkdir /email_parsing

WORKDIR /email/parsing


ENTRYPOINT ["python", "./"]

Create container from image:

docker build . -t zabbix/parse_email:1.0.0

Install Docker on Rundeck, and add Rundeck user to Docker group

usermod -a -G docker rundeck
systemctl restart docker
systemctl restart rundeckd

Create Rundeck job-Local Command


Create password vault for mailbox – see this post for reference and specify it as parameter for script,container will be deleted after every run

docker run --rm zabbix/parse_email:1.0.0 "-password" ${option.mailboxpassword}

Dockerizing Zabbix trapper

We can create docker image for zabbix trapper commands


FROM ubuntu:latest

RUN apt-get update -y && apt-get install wget -y && wget && apt-get install zabbix-agent -y && mkdir /zabbix_sender

WORKDIR /zabbix_sender

COPY . .



while test -n "$1"; do
    case "$1" in
          shift 2

#echo $job_name

if [ "$job_name" == "some_job" ]; then

   zabbix_sender -z zabbix_host -s rundeck -k job_status[job_name] -o "job $job_name failed" -vv

i created docker container with tag “zabbix_sender”, it takes job name as parameter

If using remote registry add step for login to it:

echo password | docker login --username username --password-stdin registry_name

Now, we can add Error handler in Rundeck, so if job fails,Zabbix alert will be triggered, under command click “cog” icon and select “Add error handler”


click Command or Local Command and add following line:

docker run --rm zabbix_sender -job ${option.job_name}

job name is declared as Rundeck option

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s