|
| 1 | +# Using tedge-container-plugin with podman rootless |
| 2 | + |
| 3 | +The following page includes some hints on how to setup podman in rootless mode so that the tedge user can run commands. |
| 4 | + |
| 5 | +If you run into any errors please consult the official container engine's documentation. |
| 6 | + |
| 7 | +## Alpine Linux (with OpenRC) |
| 8 | + |
| 9 | +1. Create a home folder for the tedge user (required by podman) |
| 10 | + |
| 11 | + ```sh |
| 12 | + sudo apk --no-cache add shadow |
| 13 | + sudo mkdir -p /home/tedge/.config/containers/ |
| 14 | + sudo chown -R tedge:tedge /home/tedge |
| 15 | + sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 tedge |
| 16 | + ``` |
| 17 | + |
| 18 | + If you need/want to avoid installing the `shadow` package (which provides the `usermod` command) then you will have to manually modify the `/etc/subuid` and `/etc/subgid` files. below shows an example of how to do this. |
| 19 | + |
| 20 | + ```sh |
| 21 | + echo tedge:100000:165535 | sudo tee -a /etc/subuid |
| 22 | + echo tedge:100000:165535 | sudo tee -a /etc/subgid |
| 23 | + ``` |
| 24 | + |
| 25 | + **Note:** Technically it would be feasible to edit the default storage path in the container.conf file, however that change might be more invasive for other users who wish to run their own podman rootless containers. |
| 26 | + |
| 27 | +2. Edit the podman OpenRC service to run the api endpoint (socket) under a non-root user |
| 28 | + |
| 29 | + ```sh |
| 30 | + sudo sed -i 's/.*podman_user=.*/podman_user="tedge"/g' /etc/conf.d/podman |
| 31 | + ``` |
| 32 | + |
| 33 | +3. Restart the podman api service |
| 34 | + |
| 35 | + ```sh |
| 36 | + sudo tedgectl restart podman |
| 37 | + ``` |
| 38 | + |
| 39 | + **Note:** You can also run the openrc specific commands, `tedgectl` just makes it easier and is service manager agnostic. |
| 40 | + |
| 41 | +4. Edit the tedge-container service to run using the tedge user (instead of root) |
| 42 | + |
| 43 | + **OpenRC** |
| 44 | + |
| 45 | + Change the `command_user` to use `tedge` |
| 46 | + |
| 47 | + ```sh |
| 48 | + sudo sed -i 's/.*command_user=.*/command_user="tedge"/g' /etc/conf.d/tedge-container-plugin |
| 49 | + ``` |
| 50 | + |
| 51 | +5. Restart the tedge-container-plugin service |
| 52 | + |
| 53 | + ```sh |
| 54 | + sudo tedgectl restart tedge-container-plugin |
| 55 | + ``` |
| 56 | + |
| 57 | + **Note:** You can also run the openrc specific commands, `tedgectl` just makes it easier and is service manager agnostic. |
0 commit comments