Can you run GUI applications in a Docker container?

前端 未结 22 2816
南旧
南旧 2020-11-22 06:12

How can you run GUI applications in a Docker container?

Are there any images that set up vncserver or something so that you can - for example - add an e

22条回答
  •  借酒劲吻你
    2020-11-22 06:27

    The other solutions should work, but here is a solution for docker-compose.

    To fix that error, you need to pass $DISPLAY and .X11-unix to docker, as well as grant the user who started docker access to xhost.

    Within docker-compose.yml file:

    version: '2'
    services:
        node:
            build: .
            container_name: node
            environment:
                - DISPLAY
            volumes:
                - /tmp/.X11-unix:/tmp/.X11-unix
    

    In terminal or script:

    • xhost +si:localuser:$USER
    • xhost +local:docker
    • export DISPLAY=$DISPLAY
    • docker-compose up

提交回复
热议问题