Skip to content

Latest commit

 

History

History
97 lines (69 loc) · 2.08 KB

run_with_docker.md

File metadata and controls

97 lines (69 loc) · 2.08 KB

Run Qt/QML with docker

Prepare

Download image from Docker Hub

$ docker pull kakalin/qt:5.12.0

Run

Ubuntu

# Expose the X server on the host
$ xhost +local:docker
$ docker run --rm -it \
    -e DISPLAY=$DISPLAY \
    -e QT_X11_NO_MITSHM=1 \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix" \
    --volume="$PWD:/home/user/qt-video-player" \
    --device /dev/snd \
    -e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
    -v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
    --privileged \
    kakalin/qt:5.12.0

Note:

macOS

Reference: X11 in docker on macOS

  1. Install XQuartz from official website or through Homebrew

    $ brew install --cask xquartz

    and then Restart OS.

  2. Open XQuartz and Check the option: XQuartz -> Preferences -> Security -> "Allow connections from network clients"

    # open XQuartz
    $ open -a XQuartz
  3. In terminal:

    # Expose the X server on the host
    $ xhost +localhost
    $ docker run --rm -it \
        -e DISPLAY=host.docker.internal:0 \
        -e QT_X11_NO_MITSHM=1 \
        --volume="/tmp:/tmp" \
        --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
        --volume="$PWD:/home/user/qt-video-player" \
        --device /dev/dri \
        --device /dev/snd \
        --privileged \
        kakalin/qt:5.12.0

Troubleshooting

  1. Qt is not found

    Opening CMakeLists.txt and uncomment list(APPEND CMAKE_PREFIX_PATH ${Your Qt path}) and modify Qt location

  2. libGL error: No matching fbConfigs or visuals found

    $ export LIBGL_ALWAYS_INDIRECT=1
  3. QGLXContext: Failed to create dummy context

    Workaround:

    $ export QT_QUICK_BACKEND=software