我正在尝试从本地主机上的停靠容器运行X11图形用户界面程序:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y firefox
ARG home=/root
WORKDIR $home
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
其中,entrypont.sh
文件位于:
#! /bin/bash
firefox &
exec bash
使用以下命令构建镜像:
docker build -t firefox-ubuntu-2004 .
并运行容器(localhost: Ubuntu 20.04):
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
DISPLAY="localhost:0"
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v $XAUTH:$XAUTH \
-v $XSOCK:$XSOCK \
-e XAUTHORITY=$XAUTH \
firefox-ubuntu-2004
运行最后一条命令的输出错误消息为:
Unable to init server: Broadway display type not supported: localhost:0
Error: cannot open display: localhost:0
发布于 2021-01-30 09:29:38
docker命令中的--net=host
应该可以完成这项工作
docker run --name myContainer -it --net=host fromMyimage:latest
同时使用host.docker.internal
而不是本地主机来连接到OSX上的docker主机。
https://stackoverflow.com/questions/62263924
复制相似问题