I am experimenting with running X11 GUI programs from a docker container on localhost:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y firefox
ARG home=/root
WORKDIR $home
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
where the entrypont.sh
file is:
#! /bin/bash
firefox &
exec bash
Building the image with:
docker build -t firefox-ubuntu-2004 .
And running the container (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
The output error message from running the last command is:
Unable to init server: Broadway display type not supported: localhost:0
Error: cannot open display: localhost:0
The --net=host
in the docker command should do the job
docker run --name myContainer -it --net=host fromMyimage:latest
along with using host.docker.internal
instead of localhost for connecting to the docker's host on OSX.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.