A program needs many things to run. It needs the right computer language. It needs the right helper files. It needs the right settings. On your computer it works. On my computer it does not. This is an old problem. Docker puts the program and all its things in one box. The box runs the same way on every computer. 一个程序要跑起来,需要很多东西:合适的语言、合适的辅助文件、合适的设置。 在你的电脑上能跑,在我的电脑上却不行——这是个老问题。Docker 把程序和它需要的所有东西装进一个盒子。 这个盒子在每台电脑上跑起来都一样。 โปรแกรมหนึ่งตัวต้องใช้หลายอย่างจึงจะทำงานได้ ต้องมีภาษาที่ถูก ต้องมีไฟล์ช่วยที่ถูก ต้องมีการตั้งค่าที่ถูก บนเครื่องคุณมันทำงาน บนเครื่องผมมันไม่ทำงาน นี่คือปัญหาเก่า Docker เอาโปรแกรมและทุกอย่างที่มันต้องใช้ ใส่ลงในกล่องเดียว กล่องนี้ทำงานเหมือนกันทุกเครื่อง
Today you will do six things. You will learn the words. You will drive four small machines. You will put Docker on your computer. You will build a React web site inside a box. You will show it to the world with Tailscale. You will send your box to Docker Hub. At the end we look at Kubernetes. 今天你会做六件事:学词、玩四台小机器、在电脑上装 Docker、在盒子里做一个 React 网站、 用 Tailscale 把它分享给全世界、把盒子推送到 Docker Hub。最后我们看看 Kubernetes。 วันนี้คุณจะทำหกอย่าง เรียนคำศัพท์ เล่นเครื่องมือเล็ก ๆ สี่ตัว ติดตั้ง Docker บนเครื่องของคุณ สร้างเว็บไซต์ React ในกล่อง แชร์ให้คนทั้งโลกดูด้วย Tailscale และส่งกล่องขึ้น Docker Hub ตอนท้ายเราจะดู Kubernetes
Twenty-two words. Every word here is a real Docker word. You will type most of them today. People all over the world say these words in English. So learning the words is learning the job. Tap say it to hear one word. Tap tell me more to read a long answer.
二十二个词。这里每个词都是真正的 Docker 用词,今天你几乎都会亲手敲一遍。全世界的人都用英语说这些词,所以学会这些词就是学会这份工作。点 say it 听发音,点 tell me more 读详细解释。
ยี่สิบสองคำ ทุกคำเป็นคำ Docker จริง วันนี้คุณจะได้พิมพ์เกือบทุกคำ คนทั่วโลกพูดคำเหล่านี้เป็นภาษาอังกฤษ เรียนคำพวกนี้คือเรียนงานจริง แตะ say it เพื่อฟังหนึ่งคำ แตะ tell me more เพื่ออ่านคำอธิบายยาว
Each machine shows a real Docker command on the left. It shows the real picture on the right. Move the slider. Press the button. The command you see is the command that made the picture. 每台机器左边是真正的 Docker 命令,右边是真正的图。拖滑块、按按钮。 你看到的命令就是画出这张图的命令。 แต่ละเครื่องแสดงคำสั่ง Docker จริงทางซ้าย และรูปจริงทางขวา เลื่อนแถบ กดปุ่ม คำสั่งที่คุณเห็นคือคำสั่งที่ทำให้เกิดรูปนั้น
An image is a cold box. It does not run. It only sits on the disk. A container is a hot box. It runs. You make a container from an image with docker run. One image can make many containers. Press run again and again and watch them appear.
镜像是一个冷盒子,它不运行,只是躺在硬盘上。容器是一个热盒子,它在运行。用 docker run 从镜像做出容器。一个镜像可以做出很多容器。多按几次 run,看它们出现。
อิมเมจคือกล่องเย็น มันไม่ทำงาน มันแค่นอนอยู่บนดิสก์ คอนเทนเนอร์คือกล่องร้อน มันทำงาน คุณสร้างคอนเทนเนอร์จากอิมเมจด้วย docker run อิมเมจหนึ่งตัวสร้างคอนเทนเนอร์ได้หลายตัว กดปุ่ม run ซ้ำ ๆ แล้วดูมันโผล่ขึ้นมา
Docker Desktop is free for one person. It is free for a small company. It is free for a school. Pick your computer below. Windows needs one extra step first. It needs WSL. A Mac does not need that step. Both take about fifteen minutes.
Docker Desktop 对个人免费,对小公司免费,对学校免费。在下面选你的电脑。Windows 要先多做一步:安装 WSL。Mac 不需要这一步。两种都大约要十五分钟。
Docker Desktop ฟรีสำหรับคนคนเดียว ฟรีสำหรับบริษัทเล็ก ฟรีสำหรับโรงเรียน เลือกเครื่องของคุณข้างล่าง Windows ต้องทำเพิ่มหนึ่งขั้นตอนก่อน คือ WSL ส่วน Mac ไม่ต้อง ทั้งสองแบบใช้เวลาประมาณสิบห้านาที
Press the Windows key and R together. Type winver.
Press Enter. You need Windows 10 or Windows 11. You need the 64-bit kind.
同时按 Windows 键和 R,输入 winver,按回车。
你需要 Windows 10 或 Windows 11,并且是 64 位的。
กด Windows พร้อม R พิมพ์ winver แล้วกด Enter
คุณต้องใช้ Windows 10 หรือ Windows 11 แบบ 64 บิต
WSL lets Windows run Linux inside it. Docker needs this. Right-click the Start button. Choose Terminal (Admin). Say yes. Then type this one line. WSL 让 Windows 在里面跑 Linux,Docker 需要它。右键点开始按钮,选 终端(管理员),点“是”。然后输入这一行。 WSL ทำให้ Windows รัน Linux ข้างในได้ Docker ต้องใช้สิ่งนี้ คลิกขวาที่ปุ่ม Start เลือก Terminal (Admin) แล้วกดยืนยัน จากนั้นพิมพ์บรรทัดนี้
Wait. It takes some minutes. Then restart your computer. This step is only once, for ever. 等几分钟,然后重启电脑。这一步一辈子只做一次。 รอสักครู่ ใช้เวลาหลายนาที แล้วรีสตาร์ทเครื่อง ขั้นตอนนี้ทำครั้งเดียวตลอดไป
Go to docker.com/products/docker-desktop. Click Download for Windows. Pick AMD64 for a normal PC. The file is big, about 600 MB. 打开 docker.com/products/docker-desktop,点 Download for Windows。 普通电脑选 AMD64。文件很大,大约 600 MB。 ไปที่ docker.com/products/docker-desktop กด Download for Windows เครื่องพีซีทั่วไปให้เลือก AMD64 ไฟล์ใหญ่ประมาณ 600 MB
Double-click the file. Keep the box Use WSL 2 instead of Hyper-V ticked. Click OK. Wait. When it finishes, restart again. 双击文件。保持勾选 Use WSL 2 instead of Hyper-V,点 OK。 等它装完,再重启一次。 ดับเบิลคลิกไฟล์ ให้ติ๊กช่อง Use WSL 2 instead of Hyper-V ไว้ กด OK รอจนเสร็จ แล้วรีสตาร์ทอีกครั้ง
Open it from the Start menu. Accept the terms. You can skip the sign-in now. Look at the little whale at the bottom left. Wait until it stops moving and turns green. Green means Docker is ready. 从开始菜单打开它,接受条款,现在可以跳过登录。看左下角那只小鲸鱼, 等它不动了并变成绿色,绿色就表示 Docker 准备好了。 เปิดจากเมนู Start กดยอมรับเงื่อนไข ตอนนี้ข้ามการล็อกอินไปก่อนได้ ดูรูปวาฬเล็ก ๆ มุมล่างซ้าย รอจนมันหยุดขยับและเปลี่ยนเป็นสีเขียว สีเขียวแปลว่า Docker พร้อมแล้ว
Open PowerShell from the Start menu. Type this. 从开始菜单打开 PowerShell,输入这个。 เปิด PowerShell จากเมนู Start แล้วพิมพ์แบบนี้
Click the Apple menu at the top left. Click About This Mac. Read the chip name. It says Apple M1, M2, M3, M4 — or it says Intel. Remember it. You need macOS 13 or newer. 点左上角苹果菜单,点关于本机,看芯片名字:写着 Apple M1/M2/M3/M4, 或者写着 Intel。记住它。你需要 macOS 13 或更新的版本。 คลิกเมนูแอปเปิลมุมซ้ายบน เลือก About This Mac ดูชื่อชิป จะเขียนว่า Apple M1/M2/M3/M4 หรือเขียนว่า Intel จำไว้ คุณต้องใช้ macOS 13 ขึ้นไป
Go to docker.com/products/docker-desktop. Click Download for Mac — Apple Silicon if you saw M1, M2, M3 or M4. Click Download for Mac — Intel Chip if you saw Intel. The wrong file will not work. 打开 docker.com/products/docker-desktop。看到 M1/M2/M3/M4 就点 Apple Silicon;看到 Intel 就点 Intel Chip。下错文件是跑不起来的。 ไปที่ docker.com/products/docker-desktop ถ้าเห็น M1/M2/M3/M4 ให้กด Apple Silicon ถ้าเห็น Intel ให้กด Intel Chip ถ้าโหลดผิดจะใช้ไม่ได้
Open the file you downloaded. A window opens. Drag the blue whale onto the Applications folder. Wait for the copy to finish. 打开下载的文件,会弹出一个窗口,把蓝鲸拖到 Applications 文件夹里,等复制完成。 เปิดไฟล์ที่ดาวน์โหลด จะมีหน้าต่างขึ้นมา ลากรูปวาฬสีน้ำเงินไปวางที่โฟลเดอร์ Applications แล้วรอให้คัดลอกเสร็จ
Do you use Homebrew? Then one line does
steps 2 and 3: brew install --cask docker.
用 Homebrew 的话,一行就能完成第 2、3 步:brew install --cask docker。
ถ้าใช้ Homebrew อยู่แล้ว บรรทัดเดียวแทนขั้นที่ 2 และ 3 ได้เลย:
brew install --cask docker
Open Applications. Double-click Docker. Accept the terms. It asks for your Mac password one time. That is normal. You can skip the sign-in now. 打开 应用程序,双击 Docker,接受条款。它会要一次你的 Mac 密码, 这是正常的。现在可以跳过登录。 เปิด Applications ดับเบิลคลิก Docker กดยอมรับเงื่อนไข มันจะขอรหัสผ่านเครื่องหนึ่งครั้ง เป็นเรื่องปกติ ตอนนี้ข้ามการล็อกอินไปก่อนได้
Look at the whale at the top of the screen. Wait until Docker Desktop says Engine running in green. 看屏幕顶部那只鲸鱼,等 Docker Desktop 显示绿色的 Engine running。 ดูรูปวาฬด้านบนของหน้าจอ รอจน Docker Desktop ขึ้นคำว่า Engine running สีเขียว
Press Command and Space. Type Terminal. Press Enter.
Then type this.
按 Command + 空格,输入 Terminal,按回车,然后输入这个。
กด Command พร้อม Space พิมพ์ Terminal กด Enter
แล้วพิมพ์แบบนี้
Docker cannot find hello-world on your
computer. So it gets it from the internet. Then it runs it. You see this:
Docker 在你电脑上找不到 hello-world,就去网上取,然后运行它。你会看到这个:
Docker หาไฟล์ hello-world ในเครื่องคุณไม่เจอ จึงไปดึงจากอินเทอร์เน็ต แล้วรันมัน
คุณจะเห็นแบบนี้
React is a tool for making web pages. React needs Node. But you will not install Node. Docker will give you Node inside a box. You make the site, you write a Dockerfile, you build an image, and you run it. Nine steps. Type every line yourself.
React 是做网页的工具,React 需要 Node。但你不用装 Node,Docker 会在盒子里给你 Node。你先做出网站,再写一个 Dockerfile,然后构建镜像并运行它。一共九步,每一行都自己敲。
React คือเครื่องมือสำหรับทำหน้าเว็บ React ต้องใช้ Node แต่คุณจะไม่ติดตั้ง Node เพราะ Docker จะให้ Node ในกล่องแทน คุณสร้างเว็บ เขียน Dockerfile สร้างอิมเมจ แล้วรันมัน เก้าขั้นตอน พิมพ์เองทุกบรรทัด
Open your terminal first. On Windows that is PowerShell. On a Mac that is Terminal. Some commands are a little different on the two computers. Where they are different, both lines are in the box. 先打开终端:Windows 上是 PowerShell,Mac 上是 Terminal。 有些命令在两种电脑上略有不同,不同的地方两行都写在框里。 เปิดเทอร์มินัลก่อน บน Windows คือ PowerShell บน Mac คือ Terminal บางคำสั่งต่างกันเล็กน้อยระหว่างสองเครื่อง ตรงที่ต่างกันจะใส่ทั้งสองบรรทัดไว้ในกล่อง
Make a new folder. Go inside it. This works the same on both computers. 新建一个文件夹,进去。两种电脑都一样。 สร้างโฟลเดอร์ใหม่ แล้วเข้าไปข้างใน ทั้งสองเครื่องเหมือนกัน
This is the first magic. The command below starts a box with Node inside. The box uses your folder. It makes the React files. Then the box goes away. Your computer stays clean. 这是第一个魔法:下面的命令启动一个装着 Node 的盒子,盒子使用你的文件夹, 造出 React 文件,然后盒子就消失了。你的电脑还是干干净净。 นี่คือเวทมนตร์อย่างแรก คำสั่งข้างล่างเปิดกล่องที่มี Node อยู่ข้างใน กล่องใช้โฟลเดอร์ของคุณ สร้างไฟล์ React ให้ แล้วกล่องก็หายไป เครื่องของคุณยังสะอาดเหมือนเดิม
It asks two questions. For the framework, choose React. For the variant, choose JavaScript. Use the arrow keys. Press Enter. 它会问两个问题:框架选 React,变体选 JavaScript。用方向键选,按回车。 มันจะถามสองคำถาม เฟรมเวิร์กให้เลือก React แบบย่อยให้เลือก JavaScript ใช้ปุ่มลูกศรเลือก แล้วกด Enter
--rm means throw the box away after.
-it means let me answer questions. -v means share this folder
with the box. -w means start in that folder. You will use these four for ever.
读懂这些参数:--rm 用完就扔掉盒子;-it 让我能回答问题;
-v 把这个文件夹分享给盒子;-w 从那个文件夹开始。这四个你会用一辈子。
อ่านแฟล็กให้เข้าใจ --rm คือทิ้งกล่องหลังใช้เสร็จ
-it คือให้ฉันตอบคำถามได้ -v คือแชร์โฟลเดอร์นี้ให้กล่อง
-w คือเริ่มที่โฟลเดอร์นั้น สี่ตัวนี้คุณจะใช้ไปตลอดNow go into the new folder. 现在进入新文件夹。 ตอนนี้เข้าไปในโฟลเดอร์ใหม่
There is no node_modules folder yet. That is fine. Docker will make it.
现在还没有 node_modules 文件夹,没关系,Docker 会造出来。
ตอนนี้ยังไม่มีโฟลเดอร์ node_modules ไม่เป็นไร Docker จะสร้างให้
Open src/App.jsx in any text editor. Delete everything. Put this in.
用任何文本编辑器打开 src/App.jsx,全部删掉,换成这个。
เปิด src/App.jsx ด้วยโปรแกรมแก้ข้อความอะไรก็ได้ ลบทั้งหมด แล้วใส่อันนี้
A Dockerfile is a recipe. Docker reads it from the top to the bottom. Make a
new file called Dockerfile. No dot, no ending. Put this in it.
Dockerfile 是一份食谱,Docker 从上往下读。
新建一个文件叫 Dockerfile,没有点,没有后缀名。写入这些。
Dockerfile คือสูตรอาหาร Docker อ่านจากบนลงล่าง
สร้างไฟล์ใหม่ชื่อ Dockerfile ไม่มีจุด ไม่มีนามสกุล แล้วใส่สิ่งนี้ลงไป
Make a file called .dockerignore. It tells Docker what to leave out. This
makes the build much faster.
新建一个文件 .dockerignore,告诉 Docker 哪些东西不要带进去,构建会快很多。
สร้างไฟล์ชื่อ .dockerignore บอก Docker ว่าไม่ต้องเอาอะไรเข้าไป
จะทำให้ build เร็วขึ้นมาก
Now cook the recipe. The dot at the end means "the recipe is in this folder". Do not forget the dot. 现在开始做这道菜。末尾的点表示“食谱在这个文件夹里”。别忘了那个点。 ตอนนี้ลงมือทำตามสูตร จุดท้ายสุดแปลว่า "สูตรอยู่ในโฟลเดอร์นี้" อย่าลืมจุด
The first time is slow. Two or three minutes. The second time is fast, because of the cache you saw in machine 3. 第一次比较慢,两三分钟;第二次很快,因为有你在第三台机器里看到的缓存。 ครั้งแรกช้า สองถึงสามนาที ครั้งที่สองเร็วมาก เพราะมีแคชอย่างที่คุณเห็นในเครื่องที่ 3
Open your browser. Go to http://localhost:8080. Your site is there. Press the button. It counts. 打开浏览器,访问 http://localhost:8080,你的网站就在那里。按那个按钮,它会计数。 เปิดเบราว์เซอร์ ไปที่ http://localhost:8080 เว็บของคุณอยู่ตรงนั้น กดปุ่มดู มันจะนับให้
-d? It means "run in the background". Without
it, the terminal is stuck until you press Ctrl+C.
-d 是什么?意思是“在后台运行”。不加它,终端会卡住,
直到你按 Ctrl+C。
-d คืออะไร? แปลว่า "รันเบื้องหลัง" ถ้าไม่ใส่
เทอร์มินัลจะค้างจนกว่าคุณจะกด Ctrl+CThe image is still there after you delete the container. Run step 8 again and you get a new one in one second. 删掉容器后镜像还在。再跑一次第 8 步,一秒钟就有一个新的。 หลังลบคอนเทนเนอร์แล้ว อิมเมจยังอยู่ ทำขั้นที่ 8 ซ้ำ คุณจะได้ตัวใหม่ในหนึ่งวินาที
Your site is on localhost. Only you can see it. Your friend in Bangkok cannot. Tailscale makes a safe road to your computer. First you share the site with your own devices. Then, with one more word, you share it with the whole internet. You do not need to open your router. You do not need to pay.
你的网站在 localhost 上,只有你能看到,曼谷的朋友看不到。Tailscale 会修一条安全的路通到你的电脑。先分享给你自己的设备,再多加一个词,就能分享给整个互联网。不用动路由器,也不用花钱。
เว็บของคุณอยู่บน localhost มีแค่คุณที่เห็น เพื่อนที่กรุงเทพฯ เห็นไม่ได้ Tailscale จะสร้างถนนปลอดภัยมาที่เครื่องคุณ ก่อนอื่นแชร์ให้อุปกรณ์ของคุณเอง แล้วเพิ่มอีกคำเดียว ก็แชร์ให้ทั้งอินเทอร์เน็ตได้ ไม่ต้องแตะเราเตอร์ ไม่ต้องเสียเงิน
Go to tailscale.com. Click Get started. Sign in with Google, Microsoft or GitHub. The free plan is for one person, up to 100 devices. That is plenty. 打开 tailscale.com,点 Get started,用 Google、Microsoft 或 GitHub 登录。 免费方案适合一个人,最多 100 台设备,足够用了。 ไปที่ tailscale.com กด Get started ล็อกอินด้วย Google, Microsoft หรือ GitHub แผนฟรีสำหรับหนึ่งคน ได้ถึง 100 อุปกรณ์ เหลือเฟือ
Windows: download the installer from
tailscale.com/download.
Run it. A small icon appears near the clock. Click it. Log in.
Mac: get it from the same page, or type brew install --cask tailscale.
Open it. Log in.
Windows:从 tailscale.com/download 下载安装程序并运行,时钟旁会出现一个小图标,
点它并登录。
Mac:同一个页面下载,或输入 brew install --cask tailscale,打开并登录。
Windows: ดาวน์โหลดตัวติดตั้งจาก tailscale.com/download แล้วรัน
จะมีไอคอนเล็ก ๆ ขึ้นข้างนาฬิกา คลิกแล้วล็อกอิน
Mac: โหลดจากหน้าเดียวกัน หรือพิมพ์ brew install --cask tailscale เปิดแล้วล็อกอิน
You see your computer and a name like my-laptop.tail1234.ts.net. That long
name is now the address of your computer. Remember it.
你会看到你的电脑和一个像 my-laptop.tail1234.ts.net 的名字。
这个长名字现在就是你电脑的地址,记住它。
คุณจะเห็นเครื่องของคุณ และชื่อแบบ my-laptop.tail1234.ts.net
ชื่อยาว ๆ นี้คือที่อยู่ของเครื่องคุณแล้ว จำไว้
Your container is on port 8080. This one line puts it on the safe road. 你的容器在 8080 端口,这一行把它放到那条安全的路上。 คอนเทนเนอร์ของคุณอยู่ที่พอร์ต 8080 บรรทัดเดียวนี้เอามันขึ้นถนนปลอดภัย
Now open https://my-laptop.tail1234.ts.net on your phone. Your phone needs
Tailscale too, and the same login. Only your devices can see it. Nobody else can.
现在在手机上打开 https://my-laptop.tail1234.ts.net。
手机也要装 Tailscale 并用同一个账号登录。只有你的设备能看到,别人看不到。
ตอนนี้เปิด https://my-laptop.tail1234.ts.net บนมือถือ
มือถือต้องมี Tailscale และล็อกอินบัญชีเดียวกัน มีแค่อุปกรณ์ของคุณที่เห็น คนอื่นไม่เห็น
Change one word. serve becomes funnel.
改一个词:serve 变成 funnel。
เปลี่ยนคำเดียว จาก serve เป็น funnel
The first time, Tailscale prints a web link. Open it. It asks you to turn Funnel on for this computer. Click yes. Then run the command again. 第一次运行时,Tailscale 会打印一个网页链接。打开它,它会问你是否为这台电脑打开 Funnel, 点“是”,然后再运行一次命令。 ครั้งแรก Tailscale จะพิมพ์ลิงก์เว็บออกมา เปิดลิงก์นั้น มันจะถามว่าจะเปิด Funnel ให้เครื่องนี้ไหม กดตกลง แล้วรันคำสั่งอีกครั้ง
Send that https:// address to anybody. It works on any phone, anywhere.
It already has a real lock icon, because Tailscale gets the certificate for you.
把那个 https:// 地址发给任何人,任何地方的任何手机都能打开。
它已经有真正的锁图标,因为 Tailscale 帮你申请了证书。
ส่งที่อยู่ https:// นั้นให้ใครก็ได้ เปิดได้จากมือถือทุกเครื่องทุกที่
และมีรูปกุญแจจริงอยู่แล้ว เพราะ Tailscale ขอใบรับรองให้คุณ
This stops both serve and funnel.
这会同时停掉 serve 和 funnel。
คำสั่งนี้หยุดทั้ง serve และ funnel
Docker Hub is a shop for images. It is free. You put your image there. Then any computer in the world can pull it and run it in one line. This is how you send your work to a friend, to a server, or to a school. Your Docker Hub name becomes part of your image name, so choose it well.
Docker Hub 是镜像的商店,免费。你把镜像放上去,世界上任何一台电脑都能一行命令拉下来运行。这就是你把作品交给朋友、交给服务器、交给学校的方式。你的 Docker Hub 用户名会成为镜像名字的一部分,所以要好好选。
Docker Hub คือร้านค้าของอิมเมจ ใช้ฟรี คุณเอาอิมเมจไปวางไว้ แล้วคอมพิวเตอร์เครื่องไหนในโลกก็ดึงมารันได้ด้วยคำสั่งเดียว นี่คือวิธีส่งงานให้เพื่อน ให้เซิร์ฟเวอร์ หรือให้โรงเรียน ชื่อผู้ใช้ Docker Hub จะกลายเป็นส่วนหนึ่งของชื่ออิมเมจ เลือกให้ดี
Go to hub.docker.com/signup. Pick a username. Use small letters and numbers only. People will see this name for years, so choose a good one. Give your email. Open the email and click the link. 打开 hub.docker.com/signup,选一个用户名,只用小写字母和数字。 这个名字别人会看很多年,好好选。填邮箱,打开邮件点确认链接。 ไปที่ hub.docker.com/signup เลือกชื่อผู้ใช้ ใช้ตัวพิมพ์เล็กกับตัวเลขเท่านั้น คนจะเห็นชื่อนี้ไปอีกหลายปี เลือกให้ดี ใส่อีเมล แล้วเปิดอีเมลกดลิงก์ยืนยัน
Do not use your real password in the terminal. Make a token instead. Click your picture at the top right → Account settings → Personal access tokens → Generate new token. Give it Read & Write. Copy the long string. You see it one time only. 不要在终端里用真实密码,改用令牌。点右上角头像 → Account settings → Personal access tokens → Generate new token,权限选 Read & Write, 复制那串长字符。它只显示一次。 อย่าใช้รหัสผ่านจริงในเทอร์มินัล ให้สร้างโทเคนแทน คลิกรูปมุมขวาบน → Account settings → Personal access tokens → Generate new token ให้สิทธิ์ Read & Write คัดลอกข้อความยาว ๆ นั้นไว้ มันแสดงครั้งเดียวเท่านั้น
It asks for a password. Paste the token. Nothing appears while you paste. That is normal.
Press Enter. You see Login Succeeded.
它会要密码,粘贴令牌。粘贴时屏幕上什么都不显示,这是正常的。按回车,
看到 Login Succeeded 就好了。
มันจะถามรหัสผ่าน ให้วางโทเคนลงไป ระหว่างวางจะไม่มีอะไรขึ้นบนจอ เป็นเรื่องปกติ
กด Enter แล้วจะเห็นคำว่า Login Succeeded
An image on Docker Hub must be called yourname/thing:version. Your local
image is only called my-site:1.0. So give it a second name.
Docker Hub 上的镜像必须叫 用户名/名字:版本。
你本地的镜像只叫 my-site:1.0,所以给它再起一个名字。
อิมเมจบน Docker Hub ต้องชื่อ ชื่อคุณ/ของ:เวอร์ชัน
อิมเมจในเครื่องคุณชื่อแค่ my-site:1.0 จึงต้องตั้งชื่อที่สองให้มัน
yourname to your real Docker Hub
name in every line below.
tag 不会复制。它只是给同一个镜像加第二个名字,两个名字指向同一个东西。
下面每一行里的 yourname 都要换成你真正的 Docker Hub 用户名。
tag ไม่ได้คัดลอก มันแค่เพิ่มชื่อที่สองให้อิมเมจเดิม ทั้งสองชื่อชี้ไปที่ของชิ้นเดียวกัน
เปลี่ยน yourname เป็นชื่อ Docker Hub จริงของคุณในทุกบรรทัดข้างล่างYou watch the layers go up one by one. When it finishes, open
hub.docker.com/r/yourname/my-site in your browser. Your box is on the
internet. Your project is checked in.
你会看到一层一层上传。传完后,在浏览器打开
hub.docker.com/r/yourname/my-site,你的盒子就在互联网上了,项目已经签入。
คุณจะเห็นเลเยอร์ทยอยอัปโหลดทีละชั้น เมื่อเสร็จแล้วเปิด
hub.docker.com/r/yourname/my-site ในเบราว์เซอร์ กล่องของคุณอยู่บนอินเทอร์เน็ตแล้ว
โปรเจกต์ของคุณถูกเช็กอินเรียบร้อย
Send this one line to a friend. It works on their computer. They do not need your code. They do not need Node. They only need Docker. 把这一行发给朋友,在他电脑上就能跑。他不需要你的代码,不需要 Node,只需要 Docker。 ส่งบรรทัดนี้ให้เพื่อน มันทำงานบนเครื่องเขาได้เลย เขาไม่ต้องมีโค้ดของคุณ ไม่ต้องมี Node ต้องมีแค่ Docker
1.0, then 1.1, then
1.2. Do not always use latest — then nobody knows what is inside.
公开镜像要小心。免费账号给你很多公开仓库和一个私有仓库。
公开意味着所有人都能读到里面的一切。绝不要把密码、API 密钥或客户名单打进镜像。
以后每次推送都改版本号:1.0、1.1、1.2。
不要老是用 latest,那样谁也不知道里面装的是什么。
ระวังอิมเมจสาธารณะ บัญชีฟรีให้พื้นที่สาธารณะหลายที่ และพื้นที่ส่วนตัวหนึ่งที่
สาธารณะแปลว่าทุกคนอ่านทุกอย่างข้างในได้ อย่าใส่รหัสผ่าน คีย์ API หรือรายชื่อลูกค้าลงในอิมเมจเด็ดขาด
ต่อไปให้เปลี่ยนเลขเวอร์ชันทุกครั้งที่ push: 1.0 แล้ว 1.1 แล้ว 1.2
อย่าใช้ latest ตลอด เพราะจะไม่มีใครรู้ว่าข้างในคืออะไรDocker runs boxes on one computer. You watch them. Kubernetes runs boxes on many computers, and it watches them for you. You write a file that says what you want. Kubernetes makes the world match the file, all day and all night. It is powerful, but it is heavy. You do not need it for one small site.
Docker 在一台电脑上跑盒子,由你盯着。Kubernetes 在很多台电脑上跑盒子,并且替你盯着。你写一个文件说明你要什么,Kubernetes 就日夜不停地让现实符合这个文件。它很强大,但也很重。做一个小网站不需要它。
Docker รันกล่องบนเครื่องเดียว โดยคุณเป็นคนเฝ้า Kubernetes รันกล่องบนหลายเครื่อง และเฝ้าให้คุณเอง คุณเขียนไฟล์บอกว่าต้องการอะไร แล้ว Kubernetes ทำให้โลกจริงตรงกับไฟล์นั้นทั้งวันทั้งคืน มันทรงพลังแต่ก็หนัก เว็บเล็ก ๆ เว็บเดียวไม่จำเป็นต้องใช้
People also write it K8s. There are eight letters between the K and the s, so they count them and write the number. You say it "kates". 人们也把它写成 K8s:K 和 s 中间有八个字母,就数出来写成数字。读作 “kates”。 คนยังเขียนย่อว่า K8s เพราะระหว่าง K กับ s มีตัวอักษรแปดตัว ก็เลยนับแล้วเขียนเป็นเลข อ่านว่า "เคทส์"
Same image you pushed. Two small files. Two commands. 还是你刚推送的那个镜像,两个小文件,两条命令。 อิมเมจตัวเดิมที่คุณเพิ่ง push ไฟล์เล็ก ๆ สองไฟล์ คำสั่งสองคำสั่ง
kubectl get nodes works on your own computer.
想免费试试?Docker Desktop 里就有 Kubernetes。打开 Settings →
Kubernetes → 勾选 Enable Kubernetes → Apply,等几分钟,
然后在自己电脑上就能用 kubectl get nodes 了。
อยากลองฟรีไหม? Docker Desktop มี Kubernetes อยู่ข้างในแล้ว เปิด Settings →
Kubernetes → ติ๊ก Enable Kubernetes → Apply รอสักครู่
จากนั้น kubectl get nodes จะใช้ได้บนเครื่องของคุณเองdocker run makes a hot one
from a cold one.
镜像是冷的,容器是热的:docker run 用冷的做出热的。
อิมเมจคือกล่องเย็น คอนเทนเนอร์คือกล่องร้อน docker run
ทำกล่องร้อนจากกล่องเย็น-p 8080:80.
左边是你的电脑,右边是盒子里:-p 8080:80。
ซ้ายคือเครื่องคุณ ขวาคือในกล่อง -p 8080:80serve → funnel.
Think before you type it.
一个词就从私有变公开:serve → funnel。打之前先想一想。
คำเดียวเปลี่ยนจากส่วนตัวเป็นสาธารณะ serve → funnel
คิดก่อนพิมพ์Thank you for learning with us today. Build a box, break it, and delete it. Nothing is lost. That is the best part. See you in the next lab. 感谢今天和我们一起学习。造一个盒子,弄坏它,再删掉它——什么都不会丢,这才是最棒的地方。下个实验室见。 ขอบคุณที่เรียนกับเราวันนี้ สร้างกล่อง ทำมันพัง แล้วลบทิ้ง ไม่มีอะไรหาย นั่นแหละคือส่วนที่ดีที่สุด แล้วเจอกันในแล็บหน้า