I was able to get xeyes to work in the article "Show windows of X11 applications running on Docker containers on the display" (https://qiita.com/hoto17296/items/7c1ba10c1575c6c38105).
The --net host
is specified as shown below.
$ docker run --rm -it \
--net host \
-e DISPLAY=$DISPLAY \
-v $HOME/.Xauthority:/root/.Xauthority \
xeyes
--net host
uses a network that can only communicate between docker host and docker container.
So you can't use it if you want to connect to the internet from docker container.
In this article, we will enable the container to access the network and use the X11 app.
Dockerfile
Difference from Original
xeyes
directly with CMD, but I'm starting / bin / bash
to try network access.bash
on the image.Contents of conf / Dockerfile
FROM alpine
RUN apk --no-cache add bash xeyes
CMD ["/bin/bash"]
docker build -t xeyes conf
xhost +local:
Difference from Original
unix $ {DISPLAY}
to the environment variable DISPLAY
./tmp/.X11-unix
with -v
to the host.docker run --rm -it \
-e DISPLAY=unix${DISPLAY} \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/.Xauthority:/root/.Xauthority \
xeyes
bash-5.0# ping www.example.com
PING www.example.com (93.184.216.34): 56 data bytes
64 bytes from 93.184.216.34: seq=0 ttl=51 time=149.040 ms
64 bytes from 93.184.216.34: seq=1 ttl=51 time=172.391 ms
64 bytes from 93.184.216.34: seq=2 ttl=51 time=195.793 ms
^C
--- www.example.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 149.040/172.408/195.793 ms
bash-5.0# xeyes
If xhost + local:
is not executed, the following error will occur.
bash-5.0# xeyes
No protocol specified
Error: Can't open display: unix:0
GitHub
I put the Dockerfile and scripts I wrote in this article on GitHub.
https://github.com/m-tmatma/xeyes-docker
Recommended Posts