> ## Content Index
> Fetch the complete content index at: https://ivans.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# Block Device Passthrough to Docker guest on Proxmox LXC
- URL: https://ivans.io/block-device-passthrough-to-docker-guest-on-proxmox-lxc/
- Published: 2022-11-26T19:56:02.000Z
- Updated: 2022-11-26T19:56:02.000Z
- Author: Ivan Smirnov
- Tags: Import 2022-12-02 03:12, #Import 2026-08-12 21:23

I run Proxmox on my homelab server, with one of my LXC's running a docker engine with all of my smallworkloads.

Recetnly, I needed to pass through block devices (`/dev/sda` , etc) to a docker container so that I could monitor SMART status (using [scrutiny](https://github.com/AnalogJ/scrutiny?ref=ivans.io)).

Since the docker engine is running on an LXC, this had some small challenges. We can solve them with some clever mapping in two places.

## Solution

### Part 1: Set up mounts on the proxmox host

Edit the appropriate LXC file on your proxmox host, and add a mount point for `/dev`

```conf
# vim /etc/pve/lxc/106.conf
mp4: /dev,mp=/mnt/dev # add this line at the bottom of your file
```

### Part 2: Map the block devices back into docker

On our docker guest, we now have the `/mnt/dev` endpoint with all of our host devices under it. 

> Note: this is incredibly insecure, and should only be done to completely trusted systems.

We don't want to mount to `/dev` inside the guest, as that would clobber the exisitng `/dev` mounts and cause various problems.

Now, inside our docker compose we can add the [devices](https://docs.docker.com/compose/compose-file/compose-file-v3/?ref=ivans.io#devices) mappings back to the expected paths:

```yaml
# https://github.com/AnalogJ/scrutiny
version: '3.4'
services:
  collector:
    image: 'ghcr.io/analogj/scrutiny:master-collector'
    cap_add:
      - SYS_RAWIO
      - SYS_ADMIN
    volumes:
      - '/run/udev:/run/udev:ro'
    environment:
      COLLECTOR_API_ENDPOINT: 'http://your.endpoint'
    devices:
      - "/mnt/dev/sda:/dev/sda" # map the device back in

```