|
| 1 | +To enhance your Killercoda lab scenario, let's integrate Podman's Quadlet feature to manage containers as systemd services. This approach aligns with Red Hat's methodologies and leverages systemd for container orchestration. |
1 | 2 |
|
| 3 | +## **Step 1: Build the Container Image** |
2 | 4 |
|
3 |
| -Ok, first let's examine whether we have some images on the machine that we |
4 |
| -can turn into systemd services. |
| 5 | +First, ensure you have the necessary files in the `~/quadlet` directory, including the `Dockerfile`. Build the image using Podman: |
5 | 6 |
|
6 | 7 | ```bash
|
7 |
| - podman images |
8 |
| -```{exec} |
| 8 | +podman build -t try-me ~/quadlet |
| 9 | +``` |
9 | 10 |
|
10 |
| -Oh, actually, we have something! It's called **try-me**. |
11 | 11 |
|
12 |
| -We don't know what it's doing. |
13 |
| -Fortunately, the previous colleague left instructions on how to deploy them in a |
14 |
| -**Docker Compose file**, so we don't have to worry too much. |
| 12 | +## **Step 2: Verify Available Images** |
15 | 13 |
|
16 |
| -Unfortunately, we are the **Red Hat team**, so we use **Podman** instead. |
17 |
| -Maybe there will be something interesting. |
| 14 | +After building, confirm the presence of the `try-me` image: |
18 | 15 |
|
19 |
| -Let's examine the **Docker Compose file**: |
| 16 | +```bash |
| 17 | +podman images |
| 18 | +``` |
| 19 | + |
| 20 | + |
| 21 | +### **Step 3: Review the Docker Compose File** |
| 22 | + |
| 23 | +Although your colleague provided a Docker Compose file, we'll translate its configurations to Quadlet for systemd integration. Examine the file to understand the service requirements: |
20 | 24 |
|
21 | 25 | ```bash
|
22 | 26 | less docker-compose.yml
|
23 |
| -```{exec} |
24 |
| -Ok, so we've got it—no need to worry. |
25 |
| -We need the service that |
| 27 | +``` |
| 28 | + |
| 29 | + |
| 30 | +**Service Requirements Identified:** |
| 31 | + |
| 32 | +- Mounts `/test` directory |
| 33 | + |
| 34 | +- Exposes port `8000` |
26 | 35 |
|
27 |
| -Requiers mounts /test |
28 |
| -* It has to be run on port 8000 |
29 |
| -* it needs to be preseinatnt |
30 |
| -* And i has to execute |
31 |
| -* serve to properly use the conaienr |
| 36 | +- Requires persistent storage |
32 | 37 |
|
33 |
| -Ok but how to acctualy do that we know that redhat enables us to do that |
34 |
| -wihtout generating it based on this file but how to check |
35 |
| -As i rembermer the quadlet was avaible at verison 4.4 > so mayb podman -V |
36 |
| -Or even easier just type man quadlet |
37 |
| -There u have the table of options at the end of the set |
| 38 | +- Executes the `serve` command |
38 | 39 |
|
| 40 | +**Step 4: Implement Quadlet for systemd Integration** |
39 | 41 |
|
| 42 | +Quadlet simplifies running Podman containers under systemd by using dedicated unit files. To utilize Quadlet, create a `.container` file describing your service. For example: |
40 | 43 |
|
41 |
| -if u evere feel stuck therse an option for u to |
| 44 | +```ini |
| 45 | +[Unit] |
| 46 | +Description=Try-Me Container |
42 | 47 |
|
| 48 | +[Container] |
| 49 | +Image=localhost/try-me:latest |
| 50 | +Exec=serve |
| 51 | +Mount=/test:/test |
| 52 | +Port=8000:8000 |
| 53 | +[Install] |
| 54 | +WantedBy=multi-user.target |
| 55 | +``` |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +Save this file as `try-me.container` in the appropriate systemd directory, typically `/etc/containers/systemd/`. This configuration ensures that systemd manages the container, maintaining consistency with Red Hat's practices. citeturn0search6 |
| 60 | + |
| 61 | +**Step 5: Enable and Start the Service** |
| 62 | + |
| 63 | +Reload systemd to recognize the new service, then enable and start it: |
| 64 | + |
| 65 | +```bash |
| 66 | +systemctl --user daemon-reload |
| 67 | +systemctl --user enable try-me.service |
| 68 | +systemctl --user start try-me.service |
| 69 | +``` |
43 | 70 |
|
0 commit comments