...

/

Managing the Container Life Cycle

Managing the Container Life Cycle

Learn about typical container life cycle events, such as stopping, restarting, and deleting a container, and how these events impact any changes made to the container.

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:

Press + to interact
docker exec -it webserver sh

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 ...

Access this course and 1400+ top-rated courses and projects.