Skip to content

Commit 15f74e9

Browse files
committed
docs: add instructions for setting up podman in rootless mode
1 parent 542cecf commit 15f74e9

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ If your device is not finding the correct socket path for your container engine,
7979
host = "unix:///run/podman/podman.sock"
8080
```
8181

82+
### Rootless container engines
83+
84+
Running a container engine in rootless mode requires some additional setup which can't be provided in the default package, however the following pages provide some hints on how to get it setup.
85+
86+
* [podman (rootless)](./docs/PODMAN_ROOTLESS.md)
87+
88+
If you run into any problems with the rootless setup, then please consult the relevant container engine's documentation for more up-to-date instructions (and feel free to submit a PR in this repository).
89+
8290
### Install/remove single containers
8391

8492
Containers can be installed and removed via the Cumulocity Software Management interface in the Device Management Application.

docs/PODMAN_ROOTLESS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)