docker_run.py ============= `docker_run.py` is a helper script used at `chores.uninett.no` to set up and run Docker jobs. Features -------- * Automatic rebuild of Docker image, if it is changed or if it is missing. * Passing environment variables through files, to avoid showing them in the `ps` output. * Timeout on execution (default 60 seconds). * Send result of operation to a Zabbix item. Examples -------- ### Run a simple container job ``` run_docker.py --name name-of-the-job ``` ### Custom command to run ``` run_docker.py --name name-of-the-job /test/script.sh ``` ### Custom command and custom hostname ``` run_docker.py --name name-of-the-job --hostname wanted-hostname-of-container /test/script.sh ``` ### Pass username in plaintext and copy password from Jenkins environment ``` run_docker.py --name name-of-the-job --env USERNAME=testuser --env PASSWORD ``` ### Give the container access to set up a tunnel ``` run_docker.py --name name-of-the-job --device /dev/net/tun --cap-add NET_ADMIN ``` ### Custom timeout ``` run_docker.py --name name-of-the-job --timeout=30 ``` ### Report status to Zabbix This reports the result of the job to our Zabbix server. It is added to the item with key "someitem" on the host "host.example.org". "someitem" must be a "Zabbix trapper" item, with type "Numeric (unsigned)". The value is reported as "1" on success and "0" on failure. ``` run_docker.py --name name-of-the-job --zabbix-item=host.example.org:someitem ```