VFIO Passthrough to Docker container

Hi guys,

I’ve ubuntu 22.04 as bare-metal os whith the custom kernel linux 5.15.52-dfl and an intel fpga agilex 7 (connected to the motherboard with PCIe 2.0). I want to bind the fpga to a LXC container using VFIO driver, I’m new to LXC container so I don’t have a clue how to do that. First of all, is it possible to do that ? Can you give me some tips ?

This is a Docker Community Forum, but it seems your question is about LXC even though Docker is mentioned in the title. How is it related to Docker?

If it is not, you probably want to ask about it on the LXC forum

Yeah, I’m sorry. I’m trying to do that on both docker and lxc containers.

You can attach devices to containers using the --device option of docker run or the devices section of a compose file.

You can also search for “Docker vfio plugin”. I found one, but only for arm and no source, so no idea if it would help

Thank you for the help

Once I have attach a device to the container, how can I detach it ?

We are talking about a container which is an isolated process on the host. It is not like in case of a virtual machine to which you mount a USB device for example and it disappears from the host. The device option of Docker just mount the required device from /dev/ and sets some permissions. Mounted devices and volumes are part of the container definition which you can’t change without deleting the container and recreating it. In a compose file it i sjust changing the config file and running docker compose up -d again, but it will recreate the container. I think the only thing you can attach and detach (disconnect) from a running container is the network.

So, I need to destroy the container in order to detach the device. Again thanks for the help.