Docker files for IMOD
安装VNC远程服务
# 安装GNOME Desktop图形桌面服务
yum groupinstall "GNOME Desktop"
# 安装vnc
yum install tigervnc-server
# 查看系统运行模式
systemctl get-default
# 切换到桌面运行模式
systemctl set-default graphical.target
# 启动桌面模式
init 5
# 设置桌面运行模式为默认启动模式
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
# 设置vnc用systemctl来管理(第一个用户vncserver@:1.service,第二个用户vncserver@:2.service,其他以此类推)
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
# 修改vnc用户为root(其他系统用户也可以这样改)
vi /etc/systemd/system/vncserver@:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
# 刷新systemctl
systemctl daemon-reload
# 设置vnc密码(第二个用户修改密码,vncpasswd user2,其他以此类推)
vncpasswd
# 修改vnc黑名单限制,否则会出现vnc客户端连接不上的情况(/etc/sysconfig/vncservers)
1 # THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service
2 VNCSERVERS="1:root"
3 VNCSERVERARGS[1]="-geometry 1024x768 -BlacklistTimeout 0"
# 防火墙放行端口(vnc端口第一个用户5901,创建第二个用户5902,其他以此类推)
firewall-cmd --zone=public --add-port=5901/tcp --permanent
# 防火墙放行vnc服务
firewall-cmd --add-service vnc-server
# 放行好端口和服务,重启防火墙才能生效
firewall-cmd --reload
# 查看端口是否放行成功
firewall-cmd --list-port
# 启动,关闭,重启vnc
systemctl start vncserver@:1.service #启动
systemctl stop vncserver@:1.service #关闭
systemctl restart vncserver@:1.service #重启
安装X11-server
- 网络方式
# 查看当前宿主机的IP, e.g. 192.168.28.128
ifconfig
# 查看当前显示的环境变量值(需要显示屏,ssh终端不行), e.g. :0
echo $DISPLAY
#没有显示屏使用socket文件分析,e.g. X0 => :0
ll /tmp/.X11-unix/
# 安装X11-server
yum install -y xorg-x11-server-utils
# 许可所有用户都可访问xserver
xhost +
#在docker 容器内
export DISPLAY=192.168.28.128:0
# 注意环境变量需要每次进docker容器内设置,可以写在 /etc/bashrc 中
- 挂载方式
# 查看当前宿主机的IP, e.g. 192.168.28.128
ifconfig
# 查看当前显示的环境变量值(需要显示屏,ssh终端不行), e.g. :0
echo $DISPLAY
#没有显示屏使用socket文件分析,e.g. X0 => :0
ll /tmp/.X11-unix/
# 安装X11-server
yum install -y xorg-x11-server-utils
# 许可所有用户都可访问xserver
xhost +
#在docker 容器内
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY imod:imod_version
Dockerfile
###############################################################################
# CentOS 7, X11-server and IMOD-4.9.12
#
# Build with:
# sudo docker build -t imod:imod_version . \
# --build-arg IMOD_VERSION=imod_version \
# --build-arg CUDA_VERSION=cuda_version
#
# The build args are optional. To get the versions consistent with IMOD
# in general, use e.g. 4.9 for the main realease, and 4.9.12 for the
# twelfth patch release.
# Make sure you have the version you need in the imod homepage.
# https://bio3d.colorado.edu/imod/download.html
#
# Depend on:
# yum install -y xorg-x11-server-utils \
# xhost +
#
# Running IMOD requires the use of a graphical interface on the host machine,
# so the host machine needs to install x11-xserver-utils,
# and then execute the 'xhost +' command to allow all users
# to access the xserver. When the host needs to install x11-xserver-utils,
# you may also need to install the vnc service.
#
# Run with:
# sudo docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix \
# -e DISPLAY=$DISPLAY imod:imod_version
#
# Mount the xserver socket file into the docker container with the -v parameter,
# and set the DISPLAY parameter in docker
# to be consistent with the host through the -e parameter.
###############################################################################
###############################################################################
# Build stage
###############################################################################
FROM centos:7
# sofrware version
ARG IMOD_VERSION=4.9.12
ARG CUDA_VERSION=8.0
# install required packages
RUN yum install -y java python3 file which libjpeg-turbo mesa-libGLU-devel
# install IMOD
# The self-installing package will install to a directory named IMOD under /usr/local
# unless given an alternate location to /usr/local with the -dir option.
RUN curl -o imod_${IMOD_VERSION}_RHEL7-64_CUDA${CUDA_VERSION}.sh \
https://bio3d.colorado.edu/imod/AMD64-RHEL5/imod_${IMOD_VERSION}_RHEL7-64_CUDA${CUDA_VERSION}.sh \
&& rm -rf /usr/bin/python \
&& ln -s /usr/bin/python3 /usr/bin/python \
&& chmod +x imod_${IMOD_VERSION}_RHEL7-64_CUDA${CUDA_VERSION}.sh \
&& sh imod_${IMOD_VERSION}_RHEL7-64_CUDA${CUDA_VERSION}.sh -yes \
&& rm -rf /usr/bin/python \
&& ln -s /usr/bin/python2 /usr/bin/python \
网友评论