Managing the Container Life Cycle
Explore managing the Docker container life cycle by editing container files, stopping and restarting containers, and observing how changes persist. Understand best practices to avoid modifying live containers directly, ensuring you gain practical knowledge of container handling and lifecycle events.
Modifying files within a container
In this lesson, we’ll exec onto the webserver container and edit the web server configuration to display a new message on the home page. We’ll also stop and restart the container and verify your changes aren’t lost.
Warning: This lesson is for demonstration purposes only. In the real world, you shouldn’t change live containers like this. If you need to change a live container, you should create and test a new container with the required changes and then replace the existing container with the new one.
Open a new interactive session to the webserver container with the following command:
The container runs a simple Node.js web app that uses the views/home.pug file to build the app’s home page.
Run the following command to open the home.pug file in the ...