jlesage / docker-makemkv

Docker container for MakeMKV
MIT License
455 stars 52 forks source link

[Bug] Documenting how to make this container work if you are hosting docker on NixOS #195

Closed andrewlow closed 10 months ago

andrewlow commented 10 months ago

Current Behavior

A naive user on NixOS may not realize that while docker works fine, this container will fail because MakeMKV has some unique requirements about detecting the optical drives.

Expected Behavior

It would be nice if /dev/sgY wasn't required - but it is.

Steps To Reproduce

Following installation instructions for this container with docker on NixOS results in it not being able to find any optical drives.

Environment

Container creation

docker run -d \ --name=makemkv \ -p 5800:5800 \ -v /home/roo/data/makemkv:/config:rw \ -v /home/user/Videos:/output:rw \ --device=/dev/sr0 \ --device=/dev/sr1 \ --restart=unless-stopped \ jlesage/makemkv

Container log

N/A

Container inspect

No response

Anything else?

No response

andrewlow commented 10 months ago

I have a solution! The reason I am posting here is so that anyone looking for a solution can find it easier once this is closed.

NixOS when installed on a 'bare metal' machine doesn't expose the 'sg' devices at all. At first I thought this was a docker specific issue, but it turns out that the problem is NixOS itself - docker is innocent.

This forum post: https://discourse.nixos.org/t/makemkv-cant-find-my-usb-blu-ray-drive/23714 captures the problem and the solution. I will repeat here.

In the naive install / broken state - the lsscsi -g command shows the problem

$ lsscsi -g
[0:0:0:0]    cd/dvd  ASUS     DRW-1814BL       1.10  /dev/sr0   -        
[3:0:0:0]    cd/dvd  HL-DT-ST BDDVDRW CH12LS28 1.00  /dev/sr1   -     
[.. other drives cut...]   

Yeah - so the - is the issue here. We expect that there should be /dev/sgY devices listed.

We can manually fix this with this command on the NixOS host

$ sudo modprobe sg

This will cause /dev/sg0 and /dev/sg1 to appear (or did on my system)

Then the docker container will work.

If you want your NixOS install to be fixed properly - you need to add the following to your /etc/nixos/configuration.nix file

  # Add missing kernel mods to create /dev/sgY devices
  boot.kernelModules = [ "sg" ];

Now your installation will always have the /dev/sgY devices that MakeMKV requires.