- Docker on Windows
- Elton Stoneman
- 213字
- 2021-07-02 19:53:20
Understanding temporary containers and image state
My website container has an ID that starts 3472, which is the hostname 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. The intermediate container gets removed by Docker, but the HTML file it created is persisted in 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 is persisted in 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 store 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.
- Functional Python Programming
- Boost程序庫完全開發指南:深入C++”準”標準庫(第5版)
- Responsive Web Design with HTML5 and CSS3
- 看透JavaScript:原理、方法與實踐
- x86匯編語言:從實模式到保護模式(第2版)
- Flash CS6中文版應用教程(第三版)
- Python Network Programming Cookbook(Second Edition)
- Mastering AndEngine Game Development
- Mastering JavaScript Design Patterns(Second Edition)
- Go語言編程
- Access 2010數據庫應用技術實驗指導與習題選解(第2版)
- Struts 2.x權威指南
- PHP 8從入門到精通(視頻教學版)
- Ext JS 4 Plugin and Extension Development
- Google Adsense優化實戰