File: docker-worker.md

package info (click to toggle)
lava 2026.01-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 30,796 kB
  • sloc: python: 82,790; javascript: 16,658; sh: 1,364; makefile: 335
file content (127 lines) | stat: -rw-r--r-- 3,947 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Running the LAVA dispatcher in a Docker container

Running a LAVA dispatcher in a Docker container requires quite a few special
options, to ensure that the dispatcher has access to system resources that
are, in most Docker use cases, invisible to containers. This is automated by
the `lava-docker-worker` program, provided by the `lava-dispatcher-host`
package.

`lava-docker-worker` should support all use cases that the regular LAVA worker
supports, except running LXC containers. In particular, `lava-docker-work`
**does support** running other docker containers, QEMU/KVM, and other regular
device types, as long as the required user space tools are included in the LAVA
worker docker image.

## 1: install and configure lava-dispatcher-host

**lava-dispatcher-host needs to be installed in the host machine** (bare metal)
for the LAVA dispatcher to work inside a container, as well as Docker itself.

### Debian package

If you are using the Debian package, just installing it will do all necessary
setup.

### Other means

If you are installing lava-dispatcher-host in some other way, you need to run
the following command, as root:

```
# lava-dispatcher-host rules install
```

This step needs to be repeated when lava-dispatcher-host is upgraded, to make
sure you have the most up to date udev rules file for it.

## 2: start lava-docker-worker

### Debian package

To run the Docker Dispatcher, first edit
`/etc/lava-dispatcher-host/lava-docker-worker` and set the connection
parameters. At least URL and TOKEN are probably needed:

```
WORKER_NAME="--name myworker"

# ...

# Server connection
URL="https://my.lava.server/"
TOKEN="--token 0123456789012345678901234567890123456789"
```

Make sure Docker get installed from Docker's official repo. At the time of
writing this doc, Docker version `18.09.1` installed from Debian's official
repo doesn't work with `lava-docker-worker`.

```
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
```

??? tip "Debian Testing/Sid User"
    Install `docker.io` instead if the above docker CE installation script
    doesn't support your distribution.

    ```shell
    apt-get install docker.io
    ```

Then enable and start the `lava-docker-worker` service:

```
sudo systemctl enable lava-docker-worker.service
sudo systemctl start lava-docker-worker.service
```

### Other means

If you installed LAVA in a way that doesn't provide a lava-docker-worker
systemd service, you can just run `lava-docker-worker` as any user that can run
docker. You need to pass the relevant arguments to have it connect to your LAVA
server:

```
$ lava-docker-worker --url https://my.lavaserver.com/ --token 0123456789012345678901234567890123456789
```

## 3: build customized image

To build customized image for additional packages you might require, first edit
`/etc/lava-dispatcher-host/lava-docker-worker` and set the BUILD_DIR parameter
to a directory with a Dockerfile inside.

```
# Docker build directory
# Should be set to a directory with a Dockerfile inside.
BUILD_DIR="/etc/lava-dispatcher-host/build"
```

Then restart the `lava-docker-worker` service.

```
sudo systemctl restart lava-docker-worker.service
```

!!! note "Base image"

    A new `Dockerfile.lava` will be generated with the base image that matches
    your LAVA server version for building your customized image. All the `FROM`
    commands defined in your `Dockerfile` will be ignored.

## 4: provide custom tools in the container

If either of `/usr/share/lava-docker-worker` or
`/usr/local/share/lava-docker-worker` exists, they are bind monted into the
container by default, and if there is a `bin` subdirectory in any of then, that
gets added to the default $PATH.

Additionally, you can mount other host directories inside the container by
using the --mount option.  Edit `/etc/lava-dispatcher-host/lava-docker-worker`
and set the MOUNTS option:

```
MOUNTS="--mount /path/to/tools/bin:/usr/local/bin"
```