README.md 1.46 KB
Newer Older
Olav Morken's avatar
Olav Morken committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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).

18
19
* Send result of operation to a Zabbix item.

Olav Morken's avatar
Olav Morken committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
```

35
36
37
38
39
40
### Custom command and custom hostname

```
run_docker.py --name name-of-the-job --hostname wanted-hostname-of-container /test/script.sh
```

Olav Morken's avatar
Olav Morken committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
### 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
```
58
59
60
61
62
63
64
65
66
67
68
69

### 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
```