{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/16208","labels_url":"https://api.github.com/repos/docker/docker/issues/16208/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/16208/comments","events_url":"https://api.github.com/repos/docker/docker/issues/16208/events","html_url":"https://github.com/docker/docker/issues/16208","id":105742064,"number":16208,"title":"Bluetooth socket can't be opened inside container","user":{"login":"marcoh00","id":5492554,"avatar_url":"https://avatars.githubusercontent.com/u/5492554?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoh00","html_url":"https://github.com/marcoh00","followers_url":"https://api.github.com/users/marcoh00/followers","following_url":"https://api.github.com/users/marcoh00/following{/other_user}","gists_url":"https://api.github.com/users/marcoh00/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoh00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoh00/subscriptions","organizations_url":"https://api.github.com/users/marcoh00/orgs","repos_url":"https://api.github.com/users/marcoh00/repos","events_url":"https://api.github.com/users/marcoh00/events{/privacy}","received_events_url":"https://api.github.com/users/marcoh00/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-09-10T06:45:40Z","updated_at":"2015-09-13T14:25:43Z","closed_at":null,"body":"Hello,\r\n\r\nI'm trying to get my bluetooth dongle working inside a docker container. When I try to start bluetoothd it says\r\n\r\n```\r\nroot@a28c9bc0b5ef:~# /usr/local/libexec/bluetooth/bluetoothd -n\r\nbluetoothd[15]: Bluetooth daemon 5.34\r\nbluetoothd[15]: Failed to access management interface\r\nbluetoothd[15]: Adapter handling initialization failed\r\n```\r\n\r\nI traced down the code inside bluez which triggers this behavior (src/shared/mgmt.c:439):\r\n\r\n```\r\n\tfd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK,\r\n\t\t\t\t\t\t\t\tBTPROTO_HCI);\r\n```\r\n\r\nThe socket syscall always returns -1. When I \"strace\" the command I see\r\n\r\n```\r\nsocket(PF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, 1) = -1 EAFNOSUPPORT (Address family not supported by protocol)\r\n```\r\n\r\nThe same command works on the host machine without any issues. The bluetooth modules are all loaded:\r\n\r\n```\r\nroot@a28c9bc0b5ef:~# lsmod | grep bt\r\nbtusb                  28346  0 \r\nbtbcm                   4204  1 btusb\r\nbtintel                 1332  1 btusb\r\nbluetooth             315821  5 bnep,btbcm,btusb,btintel\r\n```\r\n\r\n/sys/class/bluetooth/hci0 exists both on the host as well as inside the container. It doesn't matter how I run the container. Neither --privileged nor --cap-add=ALL nor --cap-add=NET_ADMIN change this behavior. A quick glance at linux/src/bluetooth/hci_sock.c reveals that CAP_NET_ADMIN and CAP_NET_RAW should be enough to issue any command to the socket (never had anything to do with linux kernel code until yet so I don't know what exactly I'm talking about, though). I guess this is a problem with how docker(/lxc?) restricts the containers, but I don't know for sure.\r\n\r\nObligatory bug report information:\r\n\r\n```\r\n# docker version\r\nClient:\r\n Version:      1.8.1\r\n API version:  1.20\r\n Go version:   go1.4.2\r\n Git commit:   b66e5ef-dirty\r\n Built:        Wed Sep  2 19:02:45 UTC 2015\r\n OS/Arch:      linux/arm\r\n\r\nServer:\r\n Version:      1.8.1\r\n API version:  1.20\r\n Go version:   go1.4.2\r\n Git commit:   b66e5ef-dirty\r\n Built:        Wed Sep  2 19:02:45 UTC 2015\r\n OS/Arch:      linux/arm\r\n\r\n# docker info\r\nContainers: 5\r\nImages: 27\r\nStorage Driver: aufs\r\n Root Dir: /var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 37\r\n Dirperm1 Supported: true\r\nExecution Driver: native-0.2\r\nLogging Driver: json-file\r\nKernel Version: 4.1.6-v7+\r\nOperating System: Debian GNU/Linux 8 (jessie)\r\nCPUs: 4\r\nTotal Memory: 925.7 MiB\r\nName: raspberry\r\nID: T3Z3:Z6BJ:IGU5:F7HP:AGPB:LZTR:VQH2:EZUJ:HTVR:FRFX:H2RT:4V3M\r\nWARNING: No memory limit support\r\nWARNING: No swap limit support\r\n\r\n# uname -a\r\nLinux raspberry 4.1.6-v7+ #1 SMP PREEMPT Sun Aug 23 22:01:27 CEST 2015 armv7l GNU/Linux\r\n```\r\nEnvironment details: Physical (Raspberry Pi 2)\r\nHow reproducible: Always\r\nSteps to reproduce:\r\n1. Build container with bluez installed\r\n2. Run with run options mentioned above (parameters don't seem to matter anyway)\r\n3. Start bluetoothd\r\nActual results: Doesn't start up because it cannot open bluetooth socket\r\nExpected results: bluetoothd starts up just fine (at least when run with the right capabilities enabled)\r\n\r\nPS1: This also happens on amd64\r\nPS2: This also happens when using the --device switch"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/139881758","html_url":"https://github.com/docker/docker/issues/16208#issuecomment-139881758","issue_url":"https://api.github.com/repos/docker/docker/issues/16208","id":139881758,"user":{"login":"marcoh00","id":5492554,"avatar_url":"https://avatars.githubusercontent.com/u/5492554?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoh00","html_url":"https://github.com/marcoh00","followers_url":"https://api.github.com/users/marcoh00/followers","following_url":"https://api.github.com/users/marcoh00/following{/other_user}","gists_url":"https://api.github.com/users/marcoh00/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoh00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoh00/subscriptions","organizations_url":"https://api.github.com/users/marcoh00/orgs","repos_url":"https://api.github.com/users/marcoh00/repos","events_url":"https://api.github.com/users/marcoh00/events{/privacy}","received_events_url":"https://api.github.com/users/marcoh00/received_events","type":"User","site_admin":false},"created_at":"2015-09-13T14:25:43Z","updated_at":"2015-09-13T14:25:43Z","body":"Hi,\r\n\r\nI just had a quick look at the repositories you mentioned. Seems like they all depend on bluetoothd running on the host (ResinBacon for example just seems to be a wrapper which calls hcitool from inside a python script [nothing wrong with that of course!]). Without having seen hcitool's code a wild guess would be it just communicates with bluetoothd over dbus.\r\n\r\nSo\r\n```I think the right approach is to run bluetoothd in the host, and then to talk to it over D-Bus using something in the container to set up that connection, but I don't quite yet know what that is.```\r\nseems to be the only thing one can do for now :)\r\n\r\nThanks for your help!\r\n\r\nTo the docker devs: Would love to see this fixed some day! Thanks again for delivering such a nice piece of software."}}