podlet icon indicating copy to clipboard operation
podlet copied to clipboard

Special paths defined as env variables in system files should be mapped as systemd specifiers

Open rugk opened this issue 1 year ago • 9 comments

Example

E.g. say you have the following YAML:

version: "2.1"
services:
  grocy:
    image: lscr.io/linuxserver/grocy:latest
    container_name: grocy
    volumes:
      - $HOME/config:/config:Z
    ports:
      - 9283:80

This currently get's mapped as (Volume matters here):

[Container]
ContainerName=grocy
Image=lscr.io/linuxserver/grocy:latest
PublishPort=9283:80
Volume=$HOME/config:/config:Z

[Service]
Restart=always

[Install]
WantedBy=default.target

Problem

This does not work, as I dunno… some systemd thing…(?) I guess $HOME is not defined in that context.

in any case the error is something like if you want to start this Quadlet with podman:

(podman)[82122]: grocy.service: Invalid environment variable name evaluates to an empty string: HOME/config:/config:Z

Solution

It should replace some well-known env variables with their systemd equivalents. HOME should be replaced with %h e.g.

Aka the result should be this:

Volume=%h/grocy-data:/config:Z

There are more such variables: https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Specifiers

rugk avatar Jan 10 '24 23:01 rugk