Dockerfile and X11 XQuartz 2.7.8 on Mac

jerry173985發表於2021-01-05
  1. Use XQuartz version: XQuartz 2.7.8, else it may have libGL error!
  2. set XQuartz preferences --> Security --> Tick all connections
  3. in /etc/ssh/sshd_configset x11forwardingto yes (there are two x11forwarding, all set from no to yes)

The bash scripts used to run docker (after install the docker image)—>


#!/bin/bash

IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')

/usr/X11/bin/xhost + $IP &

docker  run  -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp/.X11-unix  -p 7000-7010:7000-7010 -v ~/.cache/Xauthority -v /Users/jerry/Documents/diamond:/opt/lpzrobots -it lpzrobots /bin/bash 


#docker  run --rm -e DISPLAY=$DISPLAY --net=host -v ~/.cache/Xauthority -v /home/simon/Documents/artificial/projects/diamond/lpzrobots:/opt/lpzrobots -it --name lpzrobots lpzrobots_image /bin/bash

#docker run --rm -e DISPLAY=$DISPLAY --net=host -v ~/.cache/Xauthority                                                                                -it --name lpzrobots lpzrobots_image /bin/bash

The dockerfile:

# Last time I build it ubuntu:latest was 18.04.1. File might fail in the future
# if so, update next line to that version
FROM ubuntu:18.04

RUN apt-get -y update && apt-get install -y \
    g++  make  automake libtool xutils-dev m4  libreadline-dev  libgsl0-dev \
    libglu-dev libgl1-mesa-dev freeglut3-dev  libopenscenegraph-dev \
    libqt4-dev libqt4-opengl libqt4-opengl-dev qt4-qmake  libqt4-qt3support gnuplot gnuplot-x11 \
    libncurses5-dev git firefox
RUN apt-get update
RUN apt-get install -qqy x11-apps
RUN cd /opt; git clone https://github.com/artificialsimon/diamond.git #redo

RUN echo ''\
'# configuration file for lpzrobots (automatically generated!)\n'\
'# # Where to install the simulator and utils\n'\
'PREFIX=/usr/local\n'\
'#\n'\
'# # user or developement installation\n'\
'# # Options:\n'\
'# #  DEVEL: only install the utility functions,\n'\
'# #   which is useful for development on the simulator\n'\
'# #  USER: install also the ode_robots and selforg libaries and include files\n'\
'# #   this is recommended for users\n'\
'TYPE=USER\n'\
>>/opt/diamond/Makefile.conf

RUN cd /opt/diamond; make all

RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/issue && cat /etc/motd' \
    >> /etc/bash.bashrc \
    ; echo ""\
"##################################################\n"\
"#          lpzrobots install directory:          #\n"\
"#                /opt/diamond                  #\n"\
"#                                                #\n"\
"#      More information can be found under:      #\n"\
"#    https://github.com/georgmartius/lpzrobots   #\n"\
"##################################################\n"\
>>/etc/motd

RUN echo '\n\
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH'\
 >> /root/.bashrc

相關文章