Blog #2 : Docker GUI on OS X

donut.sorawit
DOLAB
Published in
2 min readSep 29, 2018

การใช้ Docker GUI บน OS X

docker on Mac

Problem mapping port in Mac

เนื่องจากโครงสร้าง หรือ Infrastructure ไม่เหมือนกันทำให้ใช้วิธีการ mapping ไม่เหมือนกัน

Infrastructure of Linux and OS X

สำหรับ check path ที่เชื่อมต่อ docker กับ เครื่องของเรา

Click Preferences -> File Sharing

Step 1: Install brew

เพื่อนำไปติดตั้ง application อื่นๆ ด้วย Terminal บน OS X

https://brew.sh

Step 2 : Install socat and xquartz

In Terminal

brew install socat
brew cask install xquartz
open -a XQuartz
App : XQuartz

Checked : Allow connections from network clients

Click Preferences -> Security

Step 3: Set port for display

In Terminal

xhost + 127.0.0.1
export DISPLAY=docker.for.mac.localhost:0
echo $DISPLAY
Example in terminal

Step 4: Run docker

In Terminal

docker run  -it -p 8850:8888 \
-p 6650:6006 \
-p 5000:4000 \
-v $(pwd):/workdir \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
tf-py3-dockerfile \
bash
Example in terminal

Step 4: Create file and Run file “ex1.py”

In Terminal

import numpy as np
import cv2
path_image = '/workdir/DOLAB/Medium/Blog/logo-dolab.png'
img =cv2.imread(path_image)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Example in terminal test run {}.py

--

--

donut.sorawit
DOLAB
Editor for

Data Experience @Guru Square • Software Engineer • From @Thailand • founder dolab • Website:http://dolab.cc/ Email:dolab.founder@gmail.com • Facebook:dolab