- 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.
- SOA實踐
- Learn to Create WordPress Themes by Building 5 Projects
- 零基礎玩轉區塊鏈
- 信息可視化的藝術:信息可視化在英國
- 程序員面試算法寶典
- R語言數據可視化之美:專業圖表繪制指南
- Java EE 7 Development with NetBeans 8
- JAVA程序設計實驗教程
- Raspberry Pi Robotic Projects(Third Edition)
- FFmpeg開發實戰:從零基礎到短視頻上線
- uni-app跨平臺開發與應用從入門到實踐
- Java Web開發實例大全(基礎卷) (軟件工程師開發大系)
- Go語言從入門到精通
- Angular Design Patterns
- 前端架構設計