1
0
hugo/old/2016-11-04-docker-mt5.md
2024-12-21 23:10:54 +09:00

84 lines
2.2 KiB
Markdown

+++
date = "2016-11-04"
tags = ["pc"]
title = "DockerでMT5を動かす方法"
slug = "docker-mt5"
+++
## DockerでMT5を動かす方法
> dockerfile
```bash
FROM ubuntu:16.10
RUN dpkg --add-architecture i386
RUN apt-get update -y
RUN apt-get install -y software-properties-common && add-apt-repository -y ppa:ubuntu-wine/ppa
RUN apt-get install -y wine1.8 winetricks xvfb curl wget zsh
RUN apt-get purge -y software-properties-common
RUN apt-get autoclean -y
RUN curl -sLO https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe
RUN echo "alias mt5='wine ~/.wine/drive_c/Program\ Files/MetaTrader\ 5/terminal64.exe'" >> ~/.zshrc
RUN echo -e "#!/bin/sh
wine ~/.wine/drive_c/Program\ Files/MetaTrader\ 5/terminal64.exe" >> ~/main.sh && chmod +x ~/main.sh
ENV HOME /root
CMD /bin/zsh
```
```bash
$ sudo docker build -t ubuntu:base .
$ sudo docker run -ti --rm \
-e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
ubuntu:base
# wine mt5setup.exe
------------------------------------
# インストール終了後
$ sudo docker ps
$ sudo docker commit ${id} ubuntu:mt5
$ sudo docker run -ti --rm \
-e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
ubuntu:mt5
```
### Alpineでも少し頑張ったけど無理だった
ちなみに、Alpineでも少し頑張ったけど、難しかったのでやめた。
> dockerfile
```bash
FROM alpine:latest
ENV DISPLAY :0
#ENV WINEARCH win32
RUN apk update && apk add alpine-desktop xfce4 cabextract alpine-base wine
RUN apk add --no-cache xvfb curl wget zsh && \
ln -s /usr/bin/wine64 /usr/bin/wine && \
curl -sLO https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks && chmod +x winetricks && mv winetricks /usr/bin/winetricks
RUN echo 'root:root' |chpasswd
RUN adduser -S wineuser \
&& echo "wineuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
&& echo 'wineuser:wineuser' | chpasswd
USER wineuser
RUN cd && curl -sLO https://download.mql5.com/cdn/web/metaquotes.software.corp/mt5/mt5setup.exe
CMD /bin/zsh
```
```bash
$ sudo docker build -t alpine:base .
$ sudo docker run -ti --rm \
-e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
alpine:base
# cd ;WINEPREFIX=~/.win64 wine mt5setup
```