how to: run Kodi in a Docker container with audio and video
#16
Is anyone running this on Unraid? Been watching this project for a while as I've been buying parts for a new HTPC setup and I'm really looking forward to ditching Windows as the main OS.
Reply
#17
Is anyone using this with VNC or something like this? My server has no display connected, but I would like to be able to connect via VNC, etc.. x11docker has the ability, but if anyone has already done this, a small guide would be nice Wink
Reply
#18
What's the status of this project?
Reply
#19
(2019-12-31, 15:40)Marx1 Wrote: What's the status of this project?
Active. Last commit was three weeks ago, which was an update to Kodi 18.5.

https://github.com/ehough/docker-kodi
Reply
#20
May I ask if it's possible, to run this docker as a service being able to "connect" to the "head"? Xpra possibly?
Someone having this set up in a way and is able to provide infos?
Reply
#21
(2020-01-12, 17:42)Uatschitchun Wrote: May I ask if it's possible, to run this docker as a service being able to "connect" to the "head"? Xpra possibly?
I know that x11docker has (at least some) xpra capabilities. I would suggest checking out the relevant x11docker issues on GitHub or simply posting a new issue there with your question.
Reply
#22
This guide could be helpful for you guys: https://benjamin-brummer.de/2018/06/13/k...ic-beaver/
The autor installed kodi directly on the host. But he installed the xserver-xorg-legacy and configure kodi to use the monitor.
I can think of mixing docker and the X11-Server to get video and sound.
Reply
#23
What I personally would like to achieve is to start kodi as a service without direct graphical output and be able to fire up the screen anytime I like.
Have experimented with xpra & x11docker. So kodi starts against a xpra session but not open it, making it possible to attach & detach to that session from localhost or via ssh from any other pc on the network.
That way it would combine a headless kodi with being able to play audio on the server without the need to run a xserver. Being able to attach to the session makes it possible to run maintenances directly on that instance in a more comfortable way than with using the web-ui via "xpra attach"

Problem is that the x11docker xpra setup seems to be unstable and is crashing sometimes...
Reply
#24
I'm currently running kodi on an ubuntu server as per the setup in the Benjamin Brummer blog post linked above, but I'm interested in having it in a docker container.
Is it possible to use this with an existing kodi setup/library? I tried using the --homedir option but perhaps I'm misunderstanding that.
Right now I can get this to run but setting pulseaudio results in silence. ALSA works but I have pulseaudio channels remapped so not ideal.
Also any hints how to launch/manage this within portainer? I'd like to be able to set restart policies etc as with other containers but I get an error regarding "AutoRemove" and I'm not sure how to change that?
I need a "dummies guide" kind of direction...
Reply
#25
(2020-11-09, 14:15)killthewiseone Wrote: I'm currently running kodi on an ubuntu server as per the setup in the Benjamin Brummer blog post linked above, but I'm interested in having it in a docker container.
Is it possible to use this with an existing kodi setup/library? I tried using the --homedir option but perhaps I'm misunderstanding that.
Right now I can get this to run but setting pulseaudio results in silence. ALSA works but I have pulseaudio channels remapped so not ideal.
Also any hints how to launch/manage this within portainer? I'd like to be able to set restart policies etc as with other containers but I get an error regarding "AutoRemove" and I'm not sure how to change that?
I need a "dummies guide" kind of direction...
What I would suggest is that you first iron out all the details of getting x11docker setup on your host. e.g. make sure that you can run at least one of the examples and that you have audio (pulseaudio) and video. This is the most complicated part of the installation since there are so many variables. It's mainly a matter of figuring out the right incantation of x11docker options.

Once that's done, you should definitely be able to use x11docker's --home option to map your existing Kodi home directory to the container. I do this with my personal htpc and it works great.

Regarding Portainer, there's no reason that it shouldn't work; this image should behave just like any other Docker image. What's the exact error message you're seeing?
Reply
#26
(2020-11-11, 19:40)k2eric Wrote:  
What I would suggest is that you first iron out all the details of getting x11docker setup on your host. e.g. make sure that you can run at least one of the examples and that you have audio (pulseaudio) and video. This is the most complicated part of the installation since there are so many variables. It's mainly a matter of figuring out the right incantation of x11docker options.

Once that's done, you should definitely be able to use x11docker's --home option to map your existing Kodi home directory to the container. I do this with my personal htpc and it works great.

Regarding Portainer, there's no reason that it shouldn't work; this image should behave just like any other Docker image. What's the exact error message you're seeing?
 
Thanks for the response!
I did have some joy with getting pulseaudio to work. There's more for me to iron out there and will be coming back to it, it's definitely to do with my setup rather than your docker so I apologise for posting about it here.

About portainer -
The exact error I see is Failure Cannot update container a0ed79e62b0e6733c4bdb5733bbd43631f21f9be415bea04fc428ac6cccc4dd8: Restart policy cannot be updated because AutoRemove is enabled for the container

It appears that x11docker by default will remove any container when it is stopped. Or perhaps it is to do with the dockerfile options. The data persists with the --home option so it is there when you run the container again.

With my other docker containers... I manage them all from the portainer web ui. I can start/stop/restart containers as I need should I be having any issues. If the containers crash I can start them again.
With the kodi docker container, should I try to restart it, the container simply stops and then disappears. Same if I exit from the kodi power menu, the container no longer exists.
To run again I need to ssh into my ubuntu server again and do so via command line, and a new container is built, with a new ID etc.
The docker image remains.
This is part of why I want kodi to run in docker to begin with, that I might restart without have to restart the whole machine, and to start/stop without needing ssh access.

I hope that explains my use case a little better, maybe you would know if it is possible or not to manage as I am hoping...
Reply
#27
I came across this question on the x11docker github and there didn't seem to be an immediate solution, or they pointed to the issue being with portainer.
So perhaps it is not possible to use as I had imagined.
I wonder does anyone else have any creative solutions as to how they manage their kodi docker remotely?
Reply
#28
(2020-11-11, 20:22)killthewiseone Wrote: The exact error I see is Failure Cannot update container a0ed79e62b0e6733c4bdb5733bbd43631f21f9be415bea04fc428ac6cccc4dd8: Restart policy cannot be updated because AutoRemove is enabled for the container
It appears that x11docker by default will remove any container when it is stopped. Or perhaps it is to do with the dockerfile options. The data persists with the --home option so it is there when you run the container again.

With my other docker containers... I manage them all from the portainer web ui. I can start/stop/restart containers as I need should I be having any issues. If the containers crash I can start them again.
With the kodi docker container, should I try to restart it, the container simply stops and then disappears. Same if I exit from the kodi power menu, the container no longer exists.
To run again I need to ssh into my ubuntu server again and do so via command line, and a new container is built, with a new ID etc.
The docker image remains.
This is part of why I want kodi to run in docker to begin with, that I might restart without have to restart the whole machine, and to start/stop without needing ssh access.
Yep, makes sense. I think that, for the moment at least, you likely won't be able to utilize Portainer to manage the start/stop/restart of Kodi :/  x11docker "wraps" the execution of the Docker image, supplying it with the necessary configuration to talk to your system's audio and video. Since (I believe) Portainer speaks directly to the Docker daemon, it's not really compatible with x11docker.

FWIW I have a systemd unit, /etc/systemd/system/docker-kodi.service, that keeps Kodi alive. If I reboot or turn of Kodi via the power menu, it will come right back up. Hopefully that will be useful?

Code:
[Unit]
Description=Kodi
Requires=docker.service
After=network.target docker.service

[Service]
ExecStartPre=/usr/bin/docker pull erichough/kodi
ExecStart=/opt/x11docker/x11docker --xorg --gpu --home=/var/opt/kodi/kodi_home --alsa --vt 7 -- --env LANG=en_US.UTF --env KODI_COMMAND="ionice -c 3 nice kodi-standalone" -v /media/nas/htpc-media:/media:ro --cap-add SYS_NICE -- erichough/kodi
Restart=always
KillMode=process

# the rest of these options are optional; they're just used to increase security
CapabilityBoundingSet=
AmbientCapabilities=
ProtectSystem=strict
ProtectHome=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
[email protected]
SystemCallArchitectures=native
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
LockPersonality=yes
RestrictRealtime=yes
NoNewPrivileges=yes
Reply
#29
Thanks Eric.
I'll check it out.
Reply
#30
So I've been playing around and trying to learn a bit with docker.
By editing your dockerfile together with snippets of code from... well pretty much any other kodi-docker setup I could find on github(most of which are undocumented) and my current setup, I did manage to compile a version that would launch with display from within portainer. But that's as far as it got - it does not respond to keyboard input  Eek
Long way to go yet!
Reply



Logout Mark Read Team Forum Stats Members Help
how to: run Kodi in a Docker container with audio and video1
This forum uses Lukasz Tkacz MyBB addons.