Deploying MakeMKV as a container with DVD Drive Passthrough

Deploy a MakeMKV docker container using docker compose and the official MakeMKV container image with a pass-through SATA DVD drive.

Header image for article

Deploy a MakeMKV docker container using docker compose and the official MakeMKV container image with a pass-through SATA DVD drive.

I recently rediscovered a stack of (home-video) DVDs at home that should be archived before their usable shelf-life starts to run out. I decided to use MakeMKV to rip the DVDs and then I will likely pass the ripped DVD MPEG media through FFmpeg to transcode the inefficient DVD native video files from MPEG to h264, h265/HEVC, or AV1 and then store the new files as archived consumable content.

Longevity of Recordable CDs, DVDs and Blu-rays — Canadian Conservation Institute (CCI) Notes 19/1 - Canada.ca

Deploy container with docker compose

I usually place new software in /opt/ --

# mkdir -p /opt/makemkv
# vi /opt/makemkv/docker-compose.yml

Edit and paste the following docker-compose into your docker-compose.yml file.


version: '3.8'

services:
  makemkv:
    image: jlesage/makemkv
    container_name: makemkv
    environment:
      - PUID=1000
      - PGID=1000
    ports:
      - "5800:5800"  # Guac Web interface
    volumes:
      - ./makemkv/config:/config:rw
      - ./makemkv/storage:/storage:ro
      - ./makemkv/output:/output:rw
    devices:
      - /dev/sr0:/dev/sr0:rwm  # DVD/Blu-ray drive (adjust as needed, find with lsblk)
      - /dev/sg0:/dev/sg0:rwm  # SCSI generic device
    networks:
      - makemkv-network
    restart: unless-stopped

networks:
  makemkv-network:
    driver: bridge
GitHub - jlesage/docker-makemkv: Docker container for MakeMKV
Docker container for MakeMKV. Contribute to jlesage/docker-makemkv development by creating an account on GitHub.

MakeMKV docker container GitHub

Proxmox PCIe passthrough

To keep this simple, I passed though the entire SATA controller that only the DVD ROM drive is connected to in the physical host to a VM that runs docker. Many passthough scenarios will differ, this is the easiest way in my case to give the VM direct access to the SATA DVD ROM drive.

Proxmox PCIe passthrough

This can also easily be accomplished with a host to VM passthrough USB DVD drive with some modifications to the drive details being passed in the above docker-compose.yml.

For bare-metal systems, the passthrough step won't be needed.


DVD drive region restrictions

DVD drive region coding is needed for MakeMKV because DVDs are encoded with regional restrictions (Region 1 for US/Canada, Region 2 for Europe, etc.) as a form of digital rights management. Your DVD drive must be set to match the region of the disc you're trying to rip.

DVD region code - Wikipedia

Most DVD drives allow only 5 region changes before becoming permanently locked to the last region set. MakeMKV needs to read the encrypted content on the disc, so the drive's region must match the DVD's region code for the decryption process to work properly.

Without the correct region setting, MakeMKV will be unable to access or decrypt the DVD content for ripping.

Set the DVD drive region with regionset

Find the physical DVD drive with 'lsblk' – in this case the physical DVD drive is connected to the VM via a passed through SATA controller, 'sr1' or '/dev/sr1'.

# lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                         8:0    0   65G  0 disk 
├─sda1                      8:1    0    1M  0 part 
├─sda2                      8:2    0    2G  0 part /boot
└─sda3                      8:3    0   63G  0 part 
  └─ubuntu--vg-ubuntu--lv 252:0    0   63G  0 lvm  /
sdb                         8:16   0  100G  0 disk /opt
sdc                         8:32   0  200G  0 disk /mnt/transcode
sdd                         8:48   0  200G  0 disk /mnt/transcode-tdarr
sr0                        11:0    1 1024M  0 rom  
sr1                        11:1    1  7.9G  0 rom  

Use regionset to check the region and then set the region on the DVD drive if needed to your region or the region of the DVD's you will be reading. In my case no region was set on this drive as it was brand-new.

Example MakeMKV error:

"ILLEGAL REQUEST: MEDIA REGION CODE IS MISMATCHED TO LOGICAL UNIT REGION" 

Install the regionset package.

# apt install regionset

# regionset /dev/sr1
Current drive parameters for /dev/sr1:
  RPC Type: Phase II (Hardware)
  RPC Status: no region code set (bitmask=0xFF)
  Vendor may reset the RPC 4 times
  User is allowed change the region setting 5 times
Would you like to change the region setting for this drive? [y/n]: y
Enter the new region number for your drive [1..8]: 1
New RPC bitmask is 0xFE, ok? [y/n]: y
Region code set successfully.

We can see the region is now set on this drive.

# regionset /dev/sr1
Current drive parameters for /dev/sr1:
  RPC Type: Phase II (Hardware)
  RPC Status: active region code (bitmask=0xFE)
  Drive plays discs from this region(s): 1
  Vendor may reset the RPC 4 times
  User is allowed change the region setting 4 times
Would you like to change the region setting for this drive? [y/n]: n 

Access the MakeMKV Container Web Interface

Navigate to <container-host-ip>:5800 or your ingress hostname for the container, in my case, I am using a traefik ingress.

Example DVD loaded into MakeMKV

DVD drive issues & How I Solved Them

Optical Drive check failed with 'no usable optical drives found'

Before (Failed) - 2025-06-17 00:12:56

2025-06-17 00:12:56.880
[cont-init ] 54-check-optical-drive.sh: found optical drive 'MATSHITA DVD-ROM UJ8E0 1.00' [/dev/sr1, /dev/sg5]

2025-06-17 00:12:56.880
[cont-init ] 54-check-optical-drive.sh: [ OK ] associated SCSI Generic (sg) device detected: /dev/sg5.

2025-06-17 00:12:56.880
[cont-init ] 54-check-optical-drive.sh: [ ERR ] the host device /dev/sg5 is not exposed to the container.

2025-06-17 00:12:56.880
[cont-init ] 54-check-optical-drive.sh: [ OK ] associated SCSI CD-ROM (sr) device detected: /dev/sr1.

2025-06-17 00:12:56.880
[cont-init ] 54-check-optical-drive.sh: [ OK ] the host device /dev/sr1 is exposed to the container.

2025-06-17 00:12:56.885
[cont-init ] 54-check-optical-drive.sh: [ OK ] the device /dev/sr1 has proper permissions.

2025-06-17 00:12:56.896
[cont-init ] 54-check-optical-drive.sh: [ OK ] the container can write to device /dev/sr1.

2025-06-17 00:12:56.896
[cont-init ] 54-check-optical-drive.sh: no usable optical drives found.

Issue: The /dev/sg5 device was detected but not exposed to the container, causing the optical drive check to fail.


After (Fixed) - 2025-06-17 00:13:50

2025-06-17 00:13:50.672
[cont-init ] 54-check-optical-drive.sh: found optical drive 'MATSHITA DVD-ROM UJ8E0 1.00' [/dev/sr1, /dev/sg5]

2025-06-17 00:13:50.672
[cont-init ] 54-check-optical-drive.sh: [ OK ] associated SCSI Generic (sg) device detected: /dev/sg5.

2025-06-17 00:13:50.672
[cont-init ] 54-check-optical-drive.sh: [ OK ] the host device /dev/sg5 is exposed to the container.

2025-06-17 00:13:50.676
[cont-init ] 54-check-optical-drive.sh: [ OK ] the device /dev/sg5 has proper permissions.

2025-06-17 00:13:50.678
[cont-init ] 54-check-optical-drive.sh: [ OK ] the container can write to device /dev/sg5.

2025-06-17 00:13:50.678
[cont-init ] 54-check-optical-drive.sh: [ OK ] associated SCSI CD-ROM (sr) device detected: /dev/sr1.

2025-06-17 00:13:50.678
[cont-init ] 54-check-optical-drive.sh: [ OK ] the host device /dev/sr1 is exposed to the container.

2025-06-17 00:13:50.683
[cont-init ] 54-check-optical-drive.sh: [ OK ] the device /dev/sr1 has proper permissions.

2025-06-17 00:13:50.693
[cont-init ] 54-check-optical-drive.sh: [ OK ] the container can write to device /dev/sr1.

Resolution: Both /dev/sg5 and /dev/sr1 devices are now exposed to the container with correct permissions, allowing the optical drive to function normally.

Summary

The key difference is the status of the SCSI Generic device /dev/sg5:

  • Before: [ ERR ] the host device /dev/sg5 is not exposed to the container
  • After: [ OK ] the host device /dev/sg5 is exposed to the container

This correction allowed the container to access both the SCSI DVD-ROM device (/dev/sr1) and the SCSI Generic device (/dev/sg5), making the optical drive fully functional.