Skip to content

Commit

Permalink
add mac support
Browse files Browse the repository at this point in the history
  • Loading branch information
joans321 committed Oct 17, 2018
1 parent 95ffad8 commit 05bb5d4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
24 changes: 23 additions & 1 deletion docker/gui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down
44 changes: 41 additions & 3 deletions docker/gui/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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 --rm --name vnpy -u $id $display $volume vnpy /bin/bash
docker run -it -d --name vnpy $docker_args vnpy /bin/bash


Binary file added docker/gui/xquartz_preferences.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05bb5d4

Please sign in to comment.