- Docker on Windows
- Elton Stoneman
- 228字
- 2021-07-02 12:47:57
Understanding temporary containers and image state
My website container has an ID that starts with 6e3d, which is the hostname that the application inside the container should see, but that's not what the website claims. So, what went wrong? Remember that Docker executes every build instruction inside a temporary, intermediate container.
The RUN instruction to generate the HTML ran in a temporary container, so the PowerShell script wrote that container's ID as the hostname in the HTML file; this is where the container ID starting with bf37 came from. The intermediate container gets removed by Docker, but the HTML file it created persists within the image.
This is an important concept: when you build a Docker image, the instructions execute inside temporary containers. The containers are removed, but the state they write persists within the final image and will be present in any containers you run from that image. If I run multiple containers from my website image, they will all show the same hostname from the HTML file, because that's saved inside the image, which is shared by all containers.
Of course, you can also store the state in individual containers, which is not part of the image, so it's not shared between containers. I'll look at how to work with data in Docker now and then finish the chapter with a real-world Dockerfile example.
- 零起點學Linux系統管理
- 每天5分鐘玩轉Kubernetes
- PLC控制程序精編108例
- 發布!設計與部署穩定的分布式系統(第2版)
- 構建可擴展分布式系統:方法與實踐
- 新手易學:系統安裝與重裝
- Windows Phone 7.5 Data Cookbook
- 混沌工程實戰:手把手教你實現系統穩定性
- 混沌工程:復雜系統韌性實現之道
- 深入理解eBPF與可觀測性
- Kali Linux 2018:Windows Penetration Testing
- Python UNIX和Linux系統管理指南
- 鴻蒙HarmonyOS手機應用開發實戰
- bash shell腳本編程經典實例(第2版)
- 計算機應用基礎(Windows 7+Office 2010)