add mac support

This commit is contained in:
joans321 2018-10-17 20:27:09 +08:00
parent 95ffad8d92
commit 05bb5d44c4
3 changed files with 65 additions and 5 deletions

View File

@ -39,9 +39,31 @@ $ mongod --smallfiles --config /etc/mongodb.conf
# Windows 支持
Windows 使用 [Xming](http://www.straightrunning.com/XmingNotes/) 作为 X11 服务器,安装配置网络连接之后启动 docker 容器。
# OS X 支持
// TODO
由于 OS X 没有自带 X11 服务器,需要手动安装后并配置允许网络客户端连接.
* 安装 xquartz 作为 X11 服务器
~~~sh
$ brew cask install xquartz
~~~
* 打开 xquartz 并配置允许网络连接
![xquartz config](xquartz_preferences.png)
* 执行脚本启动 docker
~~~sh
$ ./run.sh
~~~
参考博客 [docker-for-mac-and-gui-applications](https://fredrikaverpil.github.io/2016/07/31/docker-for-mac-and-gui-applications/)

View File

@ -4,10 +4,48 @@ THIS_DIR=$(cd `dirname $0`; pwd -P)
TOPDIR=${THIS_DIR}/../..
id=vnpyuser
display="-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY"
ostype=Linux
display=
volume="-v ${TOPDIR}:/srv/vnpy"
docker run -it --rm --name vnpy -u $id $display $volume vnpy /bin/bash
timezone="-e TZ=UTC-8"
function os_detect() {
osname=`uname -s`
case "${osname}" in
Linux*) ostype=Linux;;
Darwin*) ostype=Mac;;
CYGWIN*) ostype=Cywin;;
MINGW*) ostype=Mingw;;
*) ostype="Unknown-${osname}"
esac
echo "Your system is : ${ostype}"
}
function osx_ip() {
ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
if [ -z "$ip" ]; then
ip=$(ifconfig en1 | grep inet | awk '$1=="inet" {print $2}')
fi
}
os_detect
if [ "${ostype}" = "Linux" ]; then
display="-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY"
elif [ "${ostype}" = "Mac" ]; then
osx_ip
display_number=`ps -ef | grep "Xquartz :\d" | grep -v xinit | awk '{ print $9; }'`
display="-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=${ip}${display_number}"
xhost + $ip
elif [ "${ostype}" = "Cywin" ]; then
elif [ "${ostype}" = "Mingw" ]; then
fi
docker_args="-u $id $display $volume $timezone"
docker run -it -d --name vnpy $docker_args vnpy /bin/bash

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB