gliderlabs/docker-alpine

Python2 cannot read keyboard input device

Open

#206 创建于 2016年8月22日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)Shell (515 fork)batch import
help wantedquestion

仓库指标

Star
 (5,391 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

I'm trying to read usb keyboard inside alpine docker container.

Run container

# docker run --privileged --rm -it -v /dev/input:/dev/input alpine sh

/ # ls /dev/input/by-path/
pci-0000:00:01.2-usb-0:1:1.0-event-mouse  platform-i8042-serio-1-event-mouse
pci-0000:00:01.2-usb-0:1:1.0-mouse        platform-i8042-serio-1-mouse
platform-i8042-serio-0-event-kbd          platform-pcspkr-event-spkr

Run python2 (Raise error)

/ # apk add -U python
/ # python
Python 2.7.12 (default, Jun 29 2016, 08:57:23)
[GCC 5.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> kbd = open('/dev/input/by-path/platform-i8042-serio-0-event-kbd', 'rb')
>>> kbd.read(16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 22] Invalid argument
>>> exit()

Run python3 (No error)

/ # apk add python3
/ # python3
Python 3.5.1 (default, May 30 2016, 16:01:04)
[GCC 5.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> kbd = open('/dev/input/by-path/platform-i8042-serio-0-event-kbd', 'rb')
>>> kbd.read(16)
^C

贡献者指南