Docker零基礎入門指南(三):Docker Hello World

原文地址: Docker零基礎入門指南(三)

Docker Hello World

Docker 容許你在容器內運行應用程序, 使用 docker run 命令來在容器內運行一個應用程序。
輸出Hello worlddocker

首先,運行下面的命令,將 image 文件從倉庫抓取到本地。code

$ docker image pull library/hello-world

上面代碼中,docker image pull是抓取 image 文件的命令。library/hello-world是 image 文件在倉庫裏面的位置,其中library是 image 文件所在的組,hello-world是 image 文件的名字。get

因爲 Docker 官方提供的 image 文件,都放在library組裏面,因此它的是默認組,能夠省略。所以,上面的命令能夠寫成下面這樣。it

$ docker image pull hello-world

抓取成功之後,就能夠在本機看到這個 image 文件了。入門

$ docker image ls

如今,運行這個 image 文件。容器

$ docker container run hello-world

注意,docker container run命令具備自動抓取 image 文件的功能。若是發現本地沒有指定的 image 文件,就會從倉庫自動抓取。所以,前面的docker image pull命令並非必需的步驟。基礎

(本文出自itcsdaixie.com,轉載請註明出處)程序

相關文章
相關標籤/搜索