Add devices to an already running container

Is there a way to add devices to a container without having to build it again? In the docker-compse.yml we add devices like /dev/ttyS0 so we can access it from the container. I would like to do this without having to rebuild my container. I’m wondering if this is even possible. I tried editing hostconfig.json but when I restart the container all the changes get reverted to the original copy of the file.

I couldn’t find a way to do this using the supervisor api too.


There is a hacky way to do this in docker; you might have some luck doing the same in Balena.

The real question is why you don’t want to rebuild your container though.

Have you considered setting ENV UDEV=1 to add all of /dev to your container? Maybe not a long term solution but could save you some rebuilding for the time being.

1 Like