執行最簡單的Docker容器hello-world
阿新 • • 發佈:2018-12-26
一 實戰
二 說明 上面實戰啟動一個docker容器,並在控制檯打印出Hello from Docker的資訊。 可以看出上面的命令分為三個部分: 這裡就引出了在Docker中兩個核心的概念:容器(container)和映象(image)。 按照官方文件的說法,容器是一個精簡到基本版本的Linux作業系統。映象是載入到一個容器中的軟體。 當執行上面的命令時,Docker做了下面的三件事: 1 檢查本地是否有名字為"hello-world"的映象。 2 如果沒有就從Docker Hub下載。 3 載入的映象到Docker容器並執行它。 執行的結果取決於這個映象是如何構建的,映象可能會執行單一的,簡單的命令,然後退出,就像上面的"hello-world"。[[email protected] ~]# systemctl start docker [[email protected] ~]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9a0669468bf7: Pull complete Digest: sha256:cf2f6d004a59f7c18ec89df311cf0f6a1c714ec924eebcbfdd759a669b90e711 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/