{"id":20301560,"url":"https://github.com/104corp/docker-workshop","last_synced_at":"2025-04-11T13:36:35.921Z","repository":{"id":38444622,"uuid":"184683164","full_name":"104corp/docker-workshop","owner":"104corp","description":"手把手帶領大家入門 Docker 世界","archived":false,"fork":false,"pushed_at":"2025-03-05T05:04:45.000Z","size":3525,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-25T09:49:25.833Z","etag":null,"topics":["docker","workshop"],"latest_commit_sha":null,"homepage":"https://104corp.github.io/docker-workshop/","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/104corp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-03T01:33:49.000Z","updated_at":"2025-03-05T05:04:42.000Z","dependencies_parsed_at":"2023-11-13T06:25:10.203Z","dependency_job_id":"61e63bb3-3583-4622-9c88-e9196de99018","html_url":"https://github.com/104corp/docker-workshop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/104corp%2Fdocker-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/104corp%2Fdocker-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/104corp%2Fdocker-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/104corp%2Fdocker-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/104corp","download_url":"https://codeload.github.com/104corp/docker-workshop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248410201,"owners_count":21098772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","workshop"],"created_at":"2024-11-14T16:26:31.674Z","updated_at":"2025-04-11T13:36:35.897Z","avatar_url":"https://github.com/104corp.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Workshop\n\n[![Build Status](https://travis-ci.com/104corp/docker-workshop.svg?branch=master)](https://travis-ci.com/104corp/docker-workshop)\n\n[Docker](https://www.docker.com/) 工作坊。\n\n開始前，先對此工作坊做點基本說明：\n\n* 主要使用 command line 操作，shell 會以 `bash` 為主\n* 文件會以 Mac / Linux 環境為主做說明，不保證 Windows 系統完全可用\n* 大多 image 裡面的 user 都會是 root，包括執行 docker 也需要 root（Linux）。為方便入門為前提，會以 root 執行來教學\n\n\u003e GUI 可以參考 [Portainer](https://www.portainer.io/)、[Kitematic](https://kitematic.com/)、[DockStation](https://dockstation.io/)，但本 workshop 說明不會討論 GUI。\n\n## 直接在原生系統上安裝 Docker 環境\n\n不同環境的安裝方法當然是不同的，但最後驗證是否安裝成功，可以打開終端機輸入下面指令：\n\n```bash\ndocker run hello-world\n```\n\n若沒出現錯誤訊息，且有出現 `Hello from Docker!` 的字眼的話，代表服務有正常啟動，可以開始使用 Docker 了。\n\n### Mac\n\n使用 [Homebrew](https://docs.brew.sh/Installation) 的 [Cask](https://github.com/Homebrew/homebrew-cask) 安裝（需要權限）：\n\n```bash\nbrew cask install docker\n```\n\n或是下載[安裝包](https://hub.docker.com/editions/community/docker-ce-desktop-mac)安裝（需要權限）。\n\n### Windows 10\n\n參考[官方文件](https://docs.docker.com/docker-for-windows/)，下載並安裝 Docker Desktop 即可。\n\n### Linux\n\n參考[官方文件](https://docs.docker.com/install/)，注意必須要是 64-bit 版本才能運行 Docker。\n\n或使用懶人包安裝：\n\n```bash\nsudo curl -fsSL https://get.docker.com/ | sh\nsudo usermod -aG docker your-user\n```\n\n\u003e 已使用 Vagrant 測試過 [`ubuntu/trusty64`](https://app.vagrantup.com/ubuntu/boxes/trusty64)、[`debian/jessie64`](https://app.vagrantup.com/debian/boxes/jessie64) 可行。[`centos/7`](https://app.vagrantup.com/centos/boxes/7) 需另外啟動 docker daemon `sudo systemctl start docker`。\n\n## 使用虛擬機安裝 Docker 環境\n\n有時候因為特殊理由，可能會不想或無法（如 Windows 7）在本機安裝 Docker，這時可以考慮使用虛擬機安裝。\n\n### Docker Machine\n\n[Docker Machine](https://docs.docker.com/machine/) 是建立 Docker 虛擬機的首選，預設的 provider 包括以下選擇：\n\n* [VirtualBox](https://docs.docker.com/machine/drivers/virtualbox/)\n* [Hyper-V](https://docs.docker.com/machine/drivers/hyper-v/)（Windows only）\n* AWS\n\n\u003e 使用 AWS 請注意防火牆要開通 local 機器的連線，Docker 使用 tcp 2376 port 連線，同時也注意不要讓其他人能連到這個 port。\n\n以 VirtualBox 為例，執行以下指令即可建立一個 Docker 虛擬機：\n\n```bash\n# 建立 Docker 虛擬機\ndocker-machine create -d virtualbox my-docker\n# 查看這台機器相關的環境參數\ndocker-machine env my-docker\n# export 環境參數，執行 docker 指令即可改直接連線到虛擬機上\neval $(docker-machine env my-docker)\n```\n\n### Vagrant\n\n[Vagrant](https://www.vagrantup.com/) 可以使用指令管理虛擬機（VM），並使用程式碼來表達環境（Infrastructure-as-code，IaC）。\n\nClone 此專案，並使用 `vagrant up` 指令即可得到 Ubuntu trusty 64-bit + Docker CE 的乾淨環境：\n\n```bash\nvagrant up\nvagrant ssh\n```\n\n### AWS\n\n除了上述方法外，也可以在 AWS 上使用 [RancherOS](https://github.com/rancher/os) 的 AMI。\n\n#### Cloud9\n\n另一個方法是使用 [AWS Cloud9](https://aws.amazon.com/tw/cloud9/) 服務：\n\n1.  起 Cloud9 服務，設定直接用預設值即可\n2.  在 Cloud9 服務，下 `curl ifconfig.co` 指令取得公開 IP：\n3.  因需要練習 port forwarding，所以必須到 EC2 服務裡，找到對應的 instance，再設定 security group\n\n### Play with Docker\n\n上述方法全部都不行的話，最後一個就是使用 [Play with Docker](https://labs.play-with-docker.com/) 服務，只要準備好 DockerHub 的帳號，即可使用。因為它是一個使用 [DinD](https://hub.docker.com/_/docker/) 做成的線上服務，所以會有兩個問題：\n\n* 它並沒有保證系統一直都可以用，所以什麼時候會壞，這是無法預期的\n* 因為使用 DinD，所以跟 port forwarding 相關的練習是無法使用瀏覽器測試的，不過可以使用 curl 指令測試\n\n## 預載 Image\n\n若知道如何使用 docker 指令下載 image 的話，可以先執行下面這些指令，先下載比較大的 image，避免當天大家都在下載造成網路過慢。\n\n```bash\ndocker pull composer:1.10\ndocker pull gradle:6.5\ndocker pull maven:3.6-alpine\ndocker pull mysql\ndocker pull nginx\ndocker pull node:10-alpine\ndocker pull node:12-alpine\ndocker pull php:7.2-alpine\ndocker pull php:7.3-alpine\ndocker pull php:7.4-alpine\ndocker pull python:3.8-alpine\ndocker pull selenium/hub:3.141.59-iron\ndocker pull selenium/node-chrome-debug:3.141.59-iron\ndocker pull selenium/node-firefox-debug:3.141.59-iron\n```\n\n## References\n\n* [Docker Tutorials and Labs](https://github.com/docker/labs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F104corp%2Fdocker-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F104corp%2Fdocker-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F104corp%2Fdocker-workshop/lists"}