Running Chromium inside Docker - Gtk: cannot open display: :0

前端 未结 4 906
無奈伤痛
無奈伤痛 2020-12-12 23:45

When I try to run chromium inside a docker container I see the following error: Gtk: cannot open display: :0

Dockerfile: (based on https://registry.hub.docker.com/u/

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 00:45

    Adding as reference (see real answer from greg)

    In Docker image add

    RUN apt-get update
    RUN apt-get install -qqy x11-apps
    

    https://people.ece.cornell.edu/skand/post/x-forwarding-on-docker/

    and then run

    sudo docker run \
        --rm \ # delete container when bash exits
        -it \ # connect TTY
        --privileged \
        --env DISPLAY=unix$DISPLAY \ # export DISPLAY env variable for X server
        -v $XAUTH:/root/.Xauthority \ # provide authority information to X server
        -v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
        -v /home/alex/coding:/coding \
        alexcpn/nvidia-cuda-grpc:1.0 bash
    

    check a sample command

    xclock
    

提交回复
热议问题