Docker opengl error


dockerでGUIは使えるようになったけどopenGL errorが出る...

libGL error:

環境:
ubuntu18
nvidia-docker2
nvidia-driver430.50

ubuntu18の場合

DockerFileを作る

FROM ubuntu:18.04
RUN apt -y update &&\
    apt install -y --no-install-recommends mesa-utils x11-apps

ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

アクセス権限を付与する

xhost local:

イメージの作成

sudo nvidia-docker build --tag opengl-ubuntu18:test .

コンテナーを走らせる

docker run --runtime=nvidia -it --name="opengl-ubuntu18" --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --privileged opengl-ubuntu18:test

確認

glxgears

成功!

ubuntu16の場合

FROM ubuntu:16.04
RUN apt -y update &&\
apt install -y --no-install-recommends mesa-utils x11-apps \
    pkg-config \
    libxau-dev \
    libxdmcp-dev \
    libxcb1-dev \
    libxext-dev \
    libx11-dev && \
    rm -rf /var/lib/apt/lists/*
COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 \
  /usr/local/lib/x86_64-linux-gnu \
  /usr/local/lib/x86_64-linux-gnu

COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu16.04 \
  /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json \
  /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json

RUN echo '/usr/local/lib/x86_64-linux-gnu' >> /etc/ld.so.conf.d/glvnd.conf && \
    ldconfig && \
    echo '/usr/local/$LIB/libGL.so.1' >> /etc/ld.so.preload && \
    echo '/usr/local/$LIB/libEGL.so.1' >> /etc/ld.so.preload

ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

imageを変えたらros:melodic ros:kineticでも出来た!
これが最小限かな?もっと簡単な方法あったら教えてください