จากอัพเดทล่าสุดของ Docker for Mac วันที่ 25 กรกฎาคม 2018 ตาม Change Logs ผมก็ได้ทำการรวบรวมข้อมูลเฉพาะส่วนที่เป็น New Features มาให้ดูกันคร่าว ๆ

Kubernetes บน Docker for Mac แบบอยู่บน Stable Release (เย้!)

เปิดใช้ได้เลยจาก Docker Preferences > Kubernetes > เลือก Enable Kubernetes แล้วเลือก Kubernetes เป็น Default orchestrator แล้วก็กด Apply

หลังจากที่ระบบสร้าง kubernetes เสร็จแล้วก็ใช้งานได้เลย ผ่าน kubectl ปกติ

SOCKS Proxy สำหรับเข้าถึง Network ภายใน Docker ได้โดยตรง

ปกติใน Docker for Mac เวลาเราสร้าง container ขึ้นมาแล้ว ip ของ container เราจะไม่สามารถเข้าถึงได้เลย ที่ทำได้คือการที่เราสามารถ expose port ออกมาเฉพาะ port ที่เรากำหนดไว้ docker run -p <host_port>:<target_port>

SOCKS server is a general purpose proxy server that establishes a TCP connection to another server on behalf of a client, then routes all the traffic back and forth between the client and the server. It works for any kind of network protocol on any port. SOCKS Version 5 adds additional support for security and UDP.

– What is the difference between a SOCKS proxy and an HTTP proxy?

ล่าสุดเราสามารถเข้าถึง network ของ container ด้วยการ ทำ SOCKS Proxy โดยจะต้องไปเพิ่ม configuration เพื่อเปิด SOCKS Proxy

$ cd ~/Library/Group\ Containers/group.com.docker/
$ vim settings.json

ทำการเพิ่ม Option "socksProxyPort" : <port> เพื่อเปิด SOCKS Proxy ที่พอร์ทที่เราต้องการ ในที่นี้ผมจะเปิดที่ 8888

{
  "linuxDaemonConfigCreationDate" : "2018-03-29 04:42:19 +0000",
  "proxyHttpMode" : "system",
  "diskPath" : "/Users/myUser/Library/Containers/com.docker.docker/Data/vms/0/Docker.qcow2",
  "diskSizeMiB" : 61035,
  "cpus" : 2,
  "memoryMiB" : 1024,
  "displayedWelcomeWhale" : true,
  "buildNumber" : "26399",
  "kubernetesInitialInstallPerformed" : true,
  "channelID" : "stable",
  "settingsVersion" : 1,
  "kubernetesEnabled" : true,
  "version" : "18.06.0-ce-mac70",
  "displayedWelcomeMessage" : true,
  "dockerAppLaunchPath" : "/Applications/Docker.app",
  "socksProxyPort" : 8888
}

จากนั้นทำการ Restart Docker for Mac จากนั้นไปเซ็ต Mac ของเราให้ใช้ SOCKS Proxy ที่พอร์ทที่เราเปิดมา

ไปที่ Apple System Preferences -> Network -> Advanced -> Proxies


จากนั้น Apply ให้เรียบร้อย แล้วลองทดสอบได้เลยครับ ผมทดสอบด้วยการรัน container nginx ขึ้นมาทดสอบ

docker run -d --name nginx nginx

Query internal IP ออกมา

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nginx

ทอสอบเข้าผ่าน IP ที่ได้ออกมา ผ่าน Safari หรือ Chrome (incognito windows) และ FireFox (เซ็ต Manual proxy configuration) จะได้พบกับหน้าตาที่คุ้นเคย


เปลี่ยน diskPath จาก qcow2 ไปเป็น raw เพื่อแก้ปัญหาจากการสร้างไฟล์จำนวนเยอะมาก

อันนี้เข้าไปที่ Docker Preferences > Reset > Reset disk image 

ขั้นตอนนี้ทำให้ข้อมูลทุกอย่างของ Docker for Mac จะถูกรีเซ็ตไปทั้งหมด

Source:
Docker Community Edition 18.06.0-ce-mac70 2018-07-25
https://github.com/docker/for-mac/issues/2670#issuecomment-372365274
Disk/image corruption with large numbers of files #2625

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: