Hi,
what is the actual difference between “devices” and “volumes” which we use in docker-compose to give access to the ports of host system inside the container ?
Volumes are for regular folders and files. devices are not regular files but a way to make a connection between the hardver and the user. /dev itself is not a device, so I would be surprised if you could use it in the devices section.
volumes:
dev: {}
doesn’t do anything in your compose file just defines a volume without using it. The “volumes” section can also be used for mounting a specific folder or file from the host. If you want ot mount a volume (managed by Docker itself) than you can’t start the name with a dot or a slash.
If you want to make one device available in the container, you can use the devices section. If you want to allow the container to manage devices, you can use the volumes sestion and mount /dev and also add privileged: true or set proper capabilities.