เนื่องจากต้องการ update Windows 10 รุ่น 2004 เพื่อใช้งาน WSL2 ที่จะสามารถใช้ Docker Desktop ได้ใน Windows Home
แต่เมื่อ Update Windows เรียบร้อยแล้วและติดตั้ง Docker Desktop มันก็โวยวายว่า

เนื่องจากต้องการ update Windows 10 รุ่น 2004 เพื่อใช้งาน WSL2 ที่จะสามารถใช้ Docker Desktop ได้ใน Windows Home
แต่เมื่อ Update Windows เรียบร้อยแล้วและติดตั้ง Docker Desktop มันก็โวยวายว่า
ติดตั้ง mongo ด้วย docker
docker run --name wrk-mongo -p 2888:27017 -d mongo --auth
จากนั้นตรวจสอบ ด้วยคำสั่ง
docker ps
error saving credentials: error storing credentials – err: exit status 1, out:
Cannot autolaunch D-Bus without X11 $DISPLAY
Ubuntu 18.04.4 LTS
Docker version 19.03.8
Install the following Packages in ubuntu fixed my issue
sudo apt install gnupg2 pass
Access to fetch at ‘http://127.0.0.1:3001/movies’ from origin ‘http://127.0.0.1:5500’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
ปัญหาเกิดจาก client พยายามจะเรียก web server ข้าม domain กัน ทำให้เกิดปัญหา Access-Control-Allow-Origin
สิ่งที่ต้องเตรียมใน workshop นี้
1 สมัคร https://www.digitalocean.com/ เพื่อเตรียมไว้สร้าง Server ทดสอบ
2 สมัคร https://www.cloudflare.com/ เพื่อตั้งค่า dns ของโดเมนและซับโดเมน
3 Unix/Linux Command เบื้องต้น เช่น cd, mkdir
4 nginx และ Docker Compose พื้นฐาน ดูได้จาก https://thana.in.th/2020/05/06/ติดตั้ง-nginx-ด้วย-docker-compose/
เมื่อเตรียมพร้อมแล้วเรามาเริ่มกันเล้ย
สร้าง Droplet ใหม่ที่ DigitalOcean
เลือก plan ต่ำสุดเพื่อนำมาทดสอบ แล้วค่อยระเบิดทิ้ง แต่ท่านใดเงินเหลือๆ เลือก 32 cpu เพื่อความลื่นปรื๊ดก็ไม่ว่ากันฮะ 555+
เริ่มจากสร้างไฟล์ docker-compose.yml
version: '2.0'
services:
web:
image: nginx:1.13.0-alpine
container_name: wrk-nginx
restart: always
ports:
- "9001:80"
volumes:
- ./html/:/usr/share/nginx/html
image: nginx:1.13.0-alpine
เลือก image nginx:1.13.0-alpine ซึ่งเป็นตัว image ที่ใช้ Alpine Linux project (โครงการของ Alpine Linux นี้ก็ถูกพัฒนาขึ้นมาเพื่อตอบโจทย์การใช้ Container ให้มีขนาดไม่เกิน 8MB และใช้พื้นที่รวมไม่เกิน 130 MB รวมถึงยังถูกออกแบบมาให้มีความปลอดภัยสูง)
วันนี้ได้ฤกษ์ migrate blog นี้ ซึ่งได้เริ่มเขียนลงบน wordpress.com ตั้งแต่ปี 2008 จากนั้นก็ migrate รอบแรกเมื่อ 5 ปีก่อนมาขึ้น DIgital Ocean ตอนนี้มันเน่ามากเป็น Lamp stack อัพอะไรไม่ไหวแล้ว ระเบิดทิ้งดีก่า
ตอนแรกตั้งใจ migrate ไป ghost แต่ลง plugin ไม่ได้เพราะ up php ที่ server เดิมไม่ผ่าน ด้วยฟามขึ้เกียจ export ไป wordpress นี่แหละวะ แต่ห่อมันด้วย docker หน่อยจะได้บาปน้อยลง 😂 มีเวลาค่อย migrate อีกรอบ
เริ่มต้นต้อง Export ก่อน ตอนแรกใช้ https://import.wp-migration.com มัน Export ได้แต่ตอนจะ Import ถ้าเกิน 512 MB ต้องซื้อ 69$
พอ export ออกมาโห 1 GB กว่าๆ เริ่มงกละ เอา export ธรรมดาดีกั่ว ฟริ้วววว
export ได้ไฟล์ xml มา 2.8 MB คิดว่าสบายละ แต่ๆๆ วิบากกรรมเพิ่งเริ่มต้น เราพักไว้ไปทำเรื่อง basic กันก่อน
WordPress Docker Official Images เราเลือกนาย https://hub.docker.com/_/wordpress/
ใน workshop ครั้งนี้ จะใช้ digital ocean โดยไปตั้งค่า subdomain ก่อนที่ network โดยเพิ่มที่ CNAME ดังนี้ blog.zity.co , test.zity.co
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the Ubuntu package database
sudo apt-get update
install Docker
sudo apt-get install -y docker-ce
sudo netstat -lpn |grep :'3000'
3000 is port i was looking for, After first command you will have Process ID for that port
kill -9 1192
in my case 1192 was process Id of process running on 3000 PORT use -9 for Force kill the process
pkill is the easiest command line utility
pkill -f node
or
pkill -f nodejs
whatever name the process runs as for your os