簡體   English   中英

編輯默認泊塢窗圖像“Hello-world”的內容

[英]Edit content of default docker image "Hello-world"

我是 Docker 新手。

我的問題是將圖像“hello-world”的默認文本從“Hello from Docker!...”更改為其他內容,例如“Hello Guys”。

我在互聯網上找到的一些解決方案必須下載一些編輯器,如 vim 或 vs code,然后編輯 dockerfile(!?); 或創建一個新容器並將默認路徑更改為新容器(!?)。 我嘗試了一些但不工作或一些不適合。 因為我只想通過終端解決這個問題(我使用 ubuntu server 20.4)。

提前致謝!

我決定回答,因為這看起來很有趣。 但我自願提供了很少的細節,因為這看起來像一個作業問題,你應該自己去了解這一切是如何運作的。 如果這不是一項任務,那么您也需要走自己的路! :)

無論如何,我對這張圖片的內部情況一無所知,我唯一的起點是官方圖片頁面,我只是從那里按照“意大利面條”查找資源、閱讀現有代碼並測試一些命令。

這里唯一要理解的重要一點是hello-world映像是scratch構建的,並且只包含一個嚴格的最小二進制文件。 所以它並不適合通過 Dockerfile 進行擴展。

這就是我僅使用命令行解決它的方法。 注意:如果您在運行以下程序時遇到錯誤,您可能需要安裝一些必要的工具,但要了解哪一個以及如何也是您旅程的一部分。

git clone https://github.com/docker-library/hello-world
cd hello-world
echo "Hello Guys!" > greetings/hello-world.txt
./update.sh
# Change below with your correct architecture if different
cd amd64/hello-world
docker build -t my_hello_world:latest .
docker run --rm my_hello_world:latest

這給出了(僅最后一步):

$ docker run --rm my_hello_world:latest 

Hello Guys!
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.
    (amd64)
 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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM