Can you run GUI applications in a Docker container?

前端 未结 22 2764
南旧
南旧 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:28

    Yet another answer in case you already built the image:

    1. invoke docker w/o sudo (How to fix docker: Got permission denied issue)

    2. share the same USER & home & passwd between host and container share (tips: use user id instead of user name)

    3. the dev folder for driver dependent libs to work well

    4. plus X11 forward.

        docker run --name=CONTAINER_NAME --network=host --privileged \
          -v /dev:/dev \
          -v `echo ~`:/home/${USER} \
          -p 8080:80 \
          --user=`id -u ${USER}` \
          --env="DISPLAY" \
          --volume="/etc/group:/etc/group:ro" \
          --volume="/etc/passwd:/etc/passwd:ro" \
          --volume="/etc/shadow:/etc/shadow:ro" \
          --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
          --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
          -it REPO:TAG /bin/bash
    

    you may ask, whats the point to use docker if so many things are the same? well, one reason I can think of is to overcome the package depency hell (https://en.wikipedia.org/wiki/Dependency_hell).

    So this type of usage is more suitable for developer I think.

提交回复
热议问题