我有一个运行着GUI应用程序的docker容器。除了应用程序试图通过向系统推送以下命令来关闭屏幕之外,所有操作都运行正常:xset -display :0.0 dpms force off
当此命令到达系统时,docker容器将失败。
以下是此容器的docker-compose.yml内容:
version: "3"
volumes:
kiosk_vol:
services:
func:
image: docker.alatimier.fr/kiosk/func:snapshot
restart: always
environment:
KIOSK_ID: ${KIOSK_ID}
ADDR: ${ADDR}
# For Linux host
DISPLAY:
# For OSX host, install socat and xquarts and create TCP bridge between the docker container and X11 window server :
# socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
#DISPLAY: docker.for.mac.localhost:0
volumes:
- kiosk_vol:/working_directory
- /tmp/.X11-unix:/tmp/.X11-unix:rw
depends_on:
- conf
ipc: "host"你知道为什么我不能从docker容器中关闭主机屏幕吗?
主机使用的是Lubuntu18.04,我测试了关闭屏幕的命令行,它工作得很好。
谢谢。
发布于 2019-02-23 02:48:13
所以我发现:
第一件事是编辑dockerfile以安装X实用程序(没有它,在docker容器中不能识别xset ):
RUN apt-get install --no-install-recommends -y x11-xserver-utils然后编辑docker-compose.yml,以便访问.Xauthority文件并传递显示名称:
version: "4"
volumes:
kiosk_vol:
services:
func:
image: docker.alatimier.fr/kiosk/func:snapshot
restart: always
environment:
KIOSK_ID: ${KIOSK_ID}
ADDR: ${ADDR}
# For Linux host
DISPLAY: $DISPLAY
# For OSX host, install socat and xquarts and create TCP bridge between the docker container and X11 window server :
# socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
#DISPLAY: docker.for.mac.localhost:0
volumes:
- kiosk_vol:/working_directory
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- $HOME/.Xauthority:/root/.Xauthority:rw
depends_on:
- conf
ipc: "host"如果有人有同样的问题,希望这能有所帮助。
https://stackoverflow.com/questions/54784133
复制相似问题