I have similiar issue, but I need to run container BEFORE kodi tries to start.
I installed MariaDB through docker
docker run -d p 3306:3306 --volume=/storage/mysql:/config -e TZ="CET-1CEST,M3.5.0,M10.5.0/3" -e MYSQL_ROOT_PASSWORD=xoxo -e=MYSQL_USER=xyxy -e=MYSQL_PASSWORD=xzxz --name mysql lsioarmhf/mariadb
Docker service is already in system.d. If I would define "--restart unless-stopped" for container, it would be started automatically, but I dont know how to control startp sequence. And I need to have DB up before Kodi start, obviously, to be able interconnect Kodi and MariaDB.
I already tried /storage/.config/system.d
[Unit]
Description=MySQL Container
Requires=service.system.docker.service
After=service.system.docker.service
Before=kodi.target
[Service]
ExecStart=/bin/sh -c "exec sh /storage/mysql_start.sh"
ExecStop=/bin/sh -c "exec sh /storage/mysql_stop.sh"
TimeoutStartSec=60
TimeoutStopSec=60
Restart=always
RestartSec=10
StartLimitInterval=0
[Install]
WantedBy=kodi.target
Display More
where mysql_start.sh is just docker start mysql but for some reason this service doesnt work...