gliderlabs/docker-alpine

Python2 cannot read keyboard input device

Open

#206 aperta il 22 ago 2016

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Shell (515 fork)batch import
help wantedquestion

Metriche repository

Star
 (5391 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor