Docker Hub 猶如 Github 一樣,存放著豐富的 images
。本文講介紹如何在 Docker Hub
上查找并且運行 whalesay image
查找 whalesay image
- 打開 https://hub.docker.com/
- 查找
whalesay
- 找到
docker/whalesay
這個 image - 打開 image 首頁,可以看到 image 的詳細信息
讓 whalesay 跑起來
- 啟動 container:
eval "$(docker-machine env dev)"
- 運行 image:
docker run docker/whale cowsay bobo
此時將會輸出:
? mydockerbuild docker run docker/whalesay cowsay bo
____
< bobo >
----
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
嘗試其它command
,你將會發現更有趣的事情:
docker run docker/whalesay cowsay hello, bobo
發生了什么
當執行 docker run docker/whale cowsay boboo
時:
- docker 檢查本地是否有
docker/whale
- 如果沒有
docker/whale
,則從 Docker Hub 上下載最新的 image - 運行
docker/whale
,并且調用 image 中的cowsay
程序,并傳入bobo
參數
此時查看本地 images
,這里會多一個 docker/whale
:
? mydockerbuild docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker/whalesay latest fb434121fc77 4 months ago 247 MB
ubuntu latest 91e54dfb1179 6 weeks ago 188.4 MB
hello-world latest af340544ed62 8 weeks ago 960 B
參考
- Find & run the whalesay image:http://docs.docker.com/mac/step_three/
- Docker Hub Home page:https://hub.docker.com/
- docker whalesay repo:https://hub.docker.com/r/docker/whalesay/