[Unit]
Description=%p container
Requires=service.system.docker.service
After=service.system.docker.service
Befora=kodi.service

[Service]
Restart=always
RestartSec=10s
TimeoutStartSec=0
ExecStartPre=-/bin/sh -c "mkdir -p /storage/%p/config /storage/%p/data"
ExecStart=/storage/.kodi/addons/service.system.docker/bin/docker run \
          --rm \
          --name=%p \
          --hostname=libreelec-%p \
          --volume=/storage/%p/config/:/etc/mysql/conf.d \
          --volume=/storage/%p/data:/var/lib/mysql \
          --publish=3306:3306 \
          --env=MYSQL_ROOT_PASSWORD=libreelec \
          --env=MYSQL_USER=kodi \
          --env=MYSQL_PASSWORD=kodi \
          %p
ExecStop=/storage/.kodi/addons/service.system.docker/bin/docker stop %p

[Install]
WantedBy=multi-user.target
